mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
🎨 Generate file history before converting doc to heading/moving blocks https://github.com/siyuan-note/siyuan/issues/14359
This commit is contained in:
parent
bdb0e52876
commit
d5d37c9b79
1 changed files with 15 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
|
|
@ -162,6 +163,20 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
|
|||
return
|
||||
}
|
||||
|
||||
// 生成文档历史 https://github.com/siyuan-note/siyuan/issues/14359
|
||||
historyDir, err := GetHistoryDir(HistoryOpUpdate)
|
||||
if nil != err {
|
||||
logging.LogErrorf("get history dir failed: %s", err)
|
||||
return
|
||||
}
|
||||
historyPath := filepath.Join(historyDir, srcTree.Box, srcTree.Path)
|
||||
absPath := filepath.Join(util.DataDir, srcTree.Box, srcTree.Path)
|
||||
if err = filelock.Copy(absPath, historyPath); err != nil {
|
||||
logging.LogErrorf("backup [path=%s] to history [%s] failed: %s", absPath, historyPath, err)
|
||||
return
|
||||
}
|
||||
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
|
||||
|
||||
// 移动前先删除引用 https://github.com/siyuan-note/siyuan/issues/7819
|
||||
sql.DeleteRefsTreeQueue(srcTree)
|
||||
sql.DeleteRefsTreeQueue(targetTree)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue