mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
075a6af7ad
commit
437ab17b26
1 changed files with 7 additions and 1 deletions
|
|
@ -453,6 +453,8 @@ func RenameAsset(oldPath, newName string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newPath := util.AssetName(newName)
|
||||||
|
|
||||||
luteEngine := NewLute()
|
luteEngine := NewLute()
|
||||||
for _, notebook := range notebooks {
|
for _, notebook := range notebooks {
|
||||||
pages := pagedPaths(filepath.Join(util.DataDir, notebook.ID), 32)
|
pages := pagedPaths(filepath.Join(util.DataDir, notebook.ID), 32)
|
||||||
|
|
@ -468,7 +470,7 @@ func RenameAsset(oldPath, newName string) {
|
||||||
return
|
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 {
|
if writeErr := filelock.NoLockFileWrite(treeAbsPath, data); nil != writeErr {
|
||||||
util.LogErrorf("write data [path=%s] failed: %s", treeAbsPath, writeErr)
|
util.LogErrorf("write data [path=%s] failed: %s", treeAbsPath, writeErr)
|
||||||
return
|
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()
|
IncSync()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue