From 437ab17b26809a63c500e168be78e0b59c310671 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 15 Jul 2022 10:55:45 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E8=B5=84=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=87=8D=E5=91=BD=E5=90=8D=20https://github.com/siyua?= =?UTF-8?q?n-note/siyuan/issues/3454?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/assets.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/model/assets.go b/kernel/model/assets.go index 3029aba1e..0e7812f65 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() }