From a8416f39c2722c7f3d5dfd4dc83e9ebaf904ca8a Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 1 Mar 2025 00:08:26 +0800 Subject: [PATCH] :bug: Deleted documents cannot be rolled back https://github.com/siyuan-note/siyuan/issues/14239 --- kernel/model/history.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/model/history.go b/kernel/model/history.go index cd98a0913..5ece95aee 100644 --- a/kernel/model/history.go +++ b/kernel/model/history.go @@ -245,7 +245,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) { } } - destPath, parentHPath, err = getRollbackDockPath(boxID, workingDoc) + destPath, parentHPath, err = getRollbackDockPath(boxID, historyPath, workingDoc) if err != nil { return } @@ -338,13 +338,16 @@ func RollbackDocHistory(boxID, historyPath string) (err error) { return nil } -func getRollbackDockPath(boxID string, workingDoc *treenode.BlockTree) (destPath, parentHPath string, err error) { - var parentID, baseName string +func getRollbackDockPath(boxID, historyPath string, workingDoc *treenode.BlockTree) (destPath, parentHPath string, err error) { + var parentID string + baseName := filepath.Base(historyPath) var parentWorkingDoc *treenode.BlockTree if nil != workingDoc { - baseName = path.Base(workingDoc.Path) parentID = path.Base(path.Dir(workingDoc.Path)) parentWorkingDoc = treenode.GetBlockTree(parentID) + } else { + parentID = filepath.Base(filepath.Dir(historyPath)) + parentWorkingDoc = treenode.GetBlockTree(parentID) } if nil != parentWorkingDoc {