🎨 重命名资源文件不再需要等待数据写入 Fix https://github.com/siyuan-note/siyuan/issues/7133

This commit is contained in:
Liang Ding 2023-01-20 09:38:11 +08:00
parent 2574163af9
commit ed68551477
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
6 changed files with 8 additions and 8 deletions

View file

@ -502,8 +502,10 @@ func RenameAsset(oldPath, newName string) (err error) {
if nil != err {
return
}
for _, notebook := range notebooks {
pages := pagedPaths(filepath.Join(util.DataDir, notebook.ID), 32)
for _, paths := range pages {
for _, treeAbsPath := range paths {
data, readErr := filelock.ReadFile(treeAbsPath)
@ -513,6 +515,7 @@ func RenameAsset(oldPath, newName string) (err error) {
return
}
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(70), filepath.Base(treeAbsPath)))
if !bytes.Contains(data, []byte(oldName)) {
continue
}
@ -541,9 +544,6 @@ func RenameAsset(oldPath, newName string) (err error) {
}
IncSync()
util.PushEndlessProgress(Conf.Language(113))
sql.WaitForWritingDatabase()
util.ReloadUI()
return
}