🎨 数据同步后需要重新加载图片 OCR 提取结果 Fix https://github.com/siyuan-note/siyuan/issues/7114

This commit is contained in:
Liang Ding 2023-01-18 16:20:57 +08:00
parent 9c626ebc0b
commit 175a938eec
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
7 changed files with 21 additions and 9 deletions

View file

@ -39,7 +39,7 @@ func main() {
model.BootSyncData() model.BootSyncData()
model.InitBoxes() model.InitBoxes()
model.InitFlashcards() model.LoadFlashcards()
model.LoadAssetsTexts() model.LoadAssetsTexts()
go model.AutoGenerateDocHistory() go model.AutoGenerateDocHistory()

View file

@ -53,7 +53,7 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang
model.BootSyncData() model.BootSyncData()
model.InitBoxes() model.InitBoxes()
model.InitFlashcards() model.LoadFlashcards()
model.LoadAssetsTexts() model.LoadAssetsTexts()
go model.AutoGenerateDocHistory() go model.AutoGenerateDocHistory()

View file

@ -176,7 +176,7 @@ func NetImg2LocalAssets(rootID string) (err error) {
} }
} }
name = strings.TrimSuffix(name, ext) name = strings.TrimSuffix(name, ext)
name = gulu.Str.SubStr(name, 63) // 插入资源文件时文件名长度最大限制 189 字节 https://github.com/siyuan-note/siyuan/issues/7099 name = gulu.Str.SubStr(name, 63) // 插入资源文件时文件名长度最大限制 63 个字 https://github.com/siyuan-note/siyuan/issues/7099
name = util.FilterFileName(name) name = util.FilterFileName(name)
name = "net-img-" + name + "-" + ast.NewNodeID() + ext name = "net-img-" + name + "-" + ast.NewNodeID() + ext
writePath := filepath.Join(assetsDirPath, name) writePath := filepath.Join(assetsDirPath, name)

View file

@ -523,7 +523,7 @@ func FullReindex() {
} }
IndexRefs() IndexRefs()
treenode.SaveBlockTree(true) treenode.SaveBlockTree(true)
InitFlashcards() LoadFlashcards()
util.PushEndlessProgress(Conf.Language(58)) util.PushEndlessProgress(Conf.Language(58))
isFullReindexing = false isFullReindexing = false

View file

@ -359,7 +359,7 @@ func AddFlashcards(deckID string, blockIDs []string) (err error) {
return return
} }
func InitFlashcards() { func LoadFlashcards() {
riffSavePath := getRiffDir() riffSavePath := getRiffDir()
if err := os.MkdirAll(riffSavePath, 0755); nil != err { if err := os.MkdirAll(riffSavePath, 0755); nil != err {
logging.LogErrorf("create riff dir [%s] failed: %s", riffSavePath, err) logging.LogErrorf("create riff dir [%s] failed: %s", riffSavePath, err)
@ -445,7 +445,7 @@ func RemoveDeck(deckID string) (err error) {
} }
} }
InitFlashcards() LoadFlashcards()
return return
} }

View file

@ -989,13 +989,17 @@ func syncRepo(exit, byHand bool) (err error) {
// 有数据变更,需要重建索引 // 有数据变更,需要重建索引
var upserts, removes []string var upserts, removes []string
var upsertTrees int var upsertTrees int
var needReloadFlashcard bool var needReloadFlashcard, needReloadOcrTexts bool
for _, file := range mergeResult.Upserts { for _, file := range mergeResult.Upserts {
upserts = append(upserts, file.Path) upserts = append(upserts, file.Path)
if strings.HasPrefix(file.Path, "/storage/riff/") { if strings.HasPrefix(file.Path, "/storage/riff/") {
needReloadFlashcard = true needReloadFlashcard = true
} }
if strings.HasPrefix(file.Path, "/data/assets/ocr-texts.json") {
needReloadOcrTexts = true
}
if strings.HasSuffix(file.Path, ".sy") { if strings.HasSuffix(file.Path, ".sy") {
upsertTrees++ upsertTrees++
} }
@ -1005,10 +1009,18 @@ func syncRepo(exit, byHand bool) (err error) {
if strings.HasPrefix(file.Path, "/storage/riff/") { if strings.HasPrefix(file.Path, "/storage/riff/") {
needReloadFlashcard = true needReloadFlashcard = true
} }
if strings.HasPrefix(file.Path, "/data/assets/ocr-texts.json") {
needReloadOcrTexts = true
}
} }
if needReloadFlashcard { if needReloadFlashcard {
InitFlashcards() LoadFlashcards()
}
if needReloadOcrTexts {
LoadAssetsTexts()
} }
cache.ClearDocsIAL() // 同步后文档树文档图标没有更新 https://github.com/siyuan-note/siyuan/issues/4939 cache.ClearDocsIAL() // 同步后文档树文档图标没有更新 https://github.com/siyuan-note/siyuan/issues/4939

View file

@ -141,7 +141,7 @@ func FilterUploadFileName(name string) string {
ret = strings.ReplaceAll(ret, "#", "") ret = strings.ReplaceAll(ret, "#", "")
ret = strings.ReplaceAll(ret, "%", "") ret = strings.ReplaceAll(ret, "%", "")
ret = strings.ReplaceAll(ret, "$", "") ret = strings.ReplaceAll(ret, "$", "")
// 插入资源文件时文件名长度最大限制 189 字节 https://github.com/siyuan-note/siyuan/issues/7099 // 插入资源文件时文件名长度最大限制 63 个字 https://github.com/siyuan-note/siyuan/issues/7099
ret = gulu.Str.SubStr(ret, 63) ret = gulu.Str.SubStr(ret, 63)
return ret return ret
} }