This commit is contained in:
Liang Ding 2022-07-15 10:55:45 +08:00
parent 075a6af7ad
commit 437ab17b26
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -453,6 +453,8 @@ func RenameAsset(oldPath, newName string) {
return
}
newPath := util.AssetName(newName)
luteEngine := NewLute()
for _, notebook := range notebooks {
pages := pagedPaths(filepath.Join(util.DataDir, notebook.ID), 32)
@ -468,7 +470,7 @@ func RenameAsset(oldPath, newName string) {
return
}
data = bytes.Replace(data, []byte(oldPath), []byte(newName), -1)
data = bytes.Replace(data, []byte(oldPath), []byte(newPath), -1)
if writeErr := filelock.NoLockFileWrite(treeAbsPath, data); nil != writeErr {
util.LogErrorf("write data [path=%s] failed: %s", treeAbsPath, writeErr)
return
@ -488,6 +490,10 @@ func RenameAsset(oldPath, newName string) {
}
}
if err = os.Rename(filepath.Join(util.DataDir, oldPath), filepath.Join(util.DataDir, newPath)); nil != err {
util.LogErrorf("rename asset [%s] failed: %s", oldPath, err)
}
IncSync()
}