mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 文档数据文件 ID 重复时自动重置 ID Fix https://github.com/siyuan-note/siyuan/issues/7340
This commit is contained in:
parent
698f130ffa
commit
1015ef4037
2 changed files with 57 additions and 45 deletions
|
|
@ -38,14 +38,18 @@ import (
|
|||
func resetTree(tree *parse.Tree, titleSuffix string) {
|
||||
tree.ID = ast.NewNodeID()
|
||||
tree.Root.ID = tree.ID
|
||||
if t, parseErr := time.Parse("20060102150405", util.TimeFromID(tree.ID)); nil == parseErr {
|
||||
titleSuffix += " " + t.Format("2006-01-02 15:04:05")
|
||||
} else {
|
||||
titleSuffix = "Duplicated " + time.Now().Format("2006-01-02 15:04:05")
|
||||
|
||||
if "" != titleSuffix {
|
||||
if t, parseErr := time.Parse("20060102150405", util.TimeFromID(tree.ID)); nil == parseErr {
|
||||
titleSuffix += " " + t.Format("2006-01-02 15:04:05")
|
||||
} else {
|
||||
titleSuffix = "Duplicated " + time.Now().Format("2006-01-02 15:04:05")
|
||||
}
|
||||
titleSuffix = "(" + titleSuffix + ")"
|
||||
titleSuffix = " " + titleSuffix
|
||||
}
|
||||
titleSuffix = "(" + titleSuffix + ")"
|
||||
tree.Root.SetIALAttr("id", tree.ID)
|
||||
tree.Root.SetIALAttr("title", tree.Root.IALAttr("title")+" "+titleSuffix)
|
||||
tree.Root.SetIALAttr("title", tree.Root.IALAttr("title")+titleSuffix)
|
||||
tree.Root.RemoveIALAttr("scroll")
|
||||
p := path.Join(path.Dir(tree.Path), tree.ID) + ".sy"
|
||||
tree.Path = p
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue