Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: 资源文件重命名 https://github.com/siyuan-note/siyuan/issues/3454

Liang Ding437ab17b2680
diff --git a/kernel/model/assets.go b/kernel/model/assets.go
index 3029aba1e8..0e7812f655 100644
--- a/kernel/model/assets.go
+++ b/kernel/model/assets.go
@@ -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()
}