From 28e4e1ef2fe1c373b9524a2c3f1cca85eb5452f4 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 10 Oct 2023 22:31:46 +0800 Subject: [PATCH] :art: Rename the .sya annotation file when renaming a PDF asset https://github.com/siyuan-note/siyuan/issues/9390 --- kernel/model/assets.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/model/assets.go b/kernel/model/assets.go index 8f651a6e662..709171a53ec 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()