Skip to content

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

:art: Rename the .sya annotation file when renaming a PDF asset https://github.com/siyuan-note/siyuan/issues/9390

Daniel28e4e1ef2fe1
diff --git a/kernel/model/assets.go b/kernel/model/assets.go
index 8f651a6e66..709171a53e 100644
--- a/kernel/model/assets.go
+++ b/kernel/model/assets.go
@@ -512,6 +512,15 @@ func RenameAsset(oldPath, newName string) (err error) {
logging.LogErrorf("copy asset [%s] failed: %s", oldPath, err)
return
}
+
+ if gulu.File.IsExist(filepath.Join(util.DataDir, oldPath+".sya")) {
+ // Rename the .sya annotation file when renaming a PDF asset https://github.com/siyuan-note/siyuan/issues/9390
+ if err = filelock.Copy(filepath.Join(util.DataDir, oldPath+".sya"), filepath.Join(util.DataDir, newPath+".sya")); nil != err {
+ logging.LogErrorf("copy PDF annotation [%s] failed: %s", oldPath+".sya", err)
+ return
+ }
+ }
+
oldName := path.Base(oldPath)
notebooks, err := ListNotebooks()