🎨 数据同步后需要重新加载图片 OCR 提取结果 Fix https://github.com/siyuan-note/siyuan/issues/7114
This commit is contained in:
parent
9c626ebc0b
commit
175a938eec
7 changed files with 21 additions and 9 deletions
|
@ -39,7 +39,7 @@ func main() {
|
|||
|
||||
model.BootSyncData()
|
||||
model.InitBoxes()
|
||||
model.InitFlashcards()
|
||||
model.LoadFlashcards()
|
||||
model.LoadAssetsTexts()
|
||||
|
||||
go model.AutoGenerateDocHistory()
|
||||
|
|
|
@ -53,7 +53,7 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang
|
|||
|
||||
model.BootSyncData()
|
||||
model.InitBoxes()
|
||||
model.InitFlashcards()
|
||||
model.LoadFlashcards()
|
||||
model.LoadAssetsTexts()
|
||||
|
||||
go model.AutoGenerateDocHistory()
|
||||
|
|
|
@ -176,7 +176,7 @@ func NetImg2LocalAssets(rootID string) (err error) {
|
|||
}
|
||||
}
|
||||
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 = "net-img-" + name + "-" + ast.NewNodeID() + ext
|
||||
writePath := filepath.Join(assetsDirPath, name)
|
||||
|
|
|
@ -523,7 +523,7 @@ func FullReindex() {
|
|||
}
|
||||
IndexRefs()
|
||||
treenode.SaveBlockTree(true)
|
||||
InitFlashcards()
|
||||
LoadFlashcards()
|
||||
|
||||
util.PushEndlessProgress(Conf.Language(58))
|
||||
isFullReindexing = false
|
||||
|
|
|
@ -359,7 +359,7 @@ func AddFlashcards(deckID string, blockIDs []string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func InitFlashcards() {
|
||||
func LoadFlashcards() {
|
||||
riffSavePath := getRiffDir()
|
||||
if err := os.MkdirAll(riffSavePath, 0755); nil != err {
|
||||
logging.LogErrorf("create riff dir [%s] failed: %s", riffSavePath, err)
|
||||
|
@ -445,7 +445,7 @@ func RemoveDeck(deckID string) (err error) {
|
|||
}
|
||||
}
|
||||
|
||||
InitFlashcards()
|
||||
LoadFlashcards()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -989,13 +989,17 @@ func syncRepo(exit, byHand bool) (err error) {
|
|||
// 有数据变更,需要重建索引
|
||||
var upserts, removes []string
|
||||
var upsertTrees int
|
||||
var needReloadFlashcard bool
|
||||
var needReloadFlashcard, needReloadOcrTexts bool
|
||||
for _, file := range mergeResult.Upserts {
|
||||
upserts = append(upserts, file.Path)
|
||||
if strings.HasPrefix(file.Path, "/storage/riff/") {
|
||||
needReloadFlashcard = true
|
||||
}
|
||||
|
||||
if strings.HasPrefix(file.Path, "/data/assets/ocr-texts.json") {
|
||||
needReloadOcrTexts = true
|
||||
}
|
||||
|
||||
if strings.HasSuffix(file.Path, ".sy") {
|
||||
upsertTrees++
|
||||
}
|
||||
|
@ -1005,10 +1009,18 @@ func syncRepo(exit, byHand bool) (err error) {
|
|||
if strings.HasPrefix(file.Path, "/storage/riff/") {
|
||||
needReloadFlashcard = true
|
||||
}
|
||||
|
||||
if strings.HasPrefix(file.Path, "/data/assets/ocr-texts.json") {
|
||||
needReloadOcrTexts = true
|
||||
}
|
||||
}
|
||||
|
||||
if needReloadFlashcard {
|
||||
InitFlashcards()
|
||||
LoadFlashcards()
|
||||
}
|
||||
|
||||
if needReloadOcrTexts {
|
||||
LoadAssetsTexts()
|
||||
}
|
||||
|
||||
cache.ClearDocsIAL() // 同步后文档树文档图标没有更新 https://github.com/siyuan-note/siyuan/issues/4939
|
||||
|
|
|
@ -141,7 +141,7 @@ func FilterUploadFileName(name string) string {
|
|||
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)
|
||||
return ret
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue