An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/17261
Danieledb3e6ff6c72
diff --git a/kernel/model/history.go b/kernel/model/history.goindex 830e5a2e30..0a2291a8bd 100644--- a/kernel/model/history.go+++ b/kernel/model/history.go@@ -235,6 +235,13 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {FlushTxQueue()+ box, err := getRollbackBox(boxID)+ if err != nil {+ logging.LogErrorf("get rollback box [%s] failed: %s", boxID, err)+ return+ }+ boxID = box.ID+srcPath := historyPathvar destPath, parentHPath stringrootID := util.GetTreeID(historyPath)@@ -322,10 +329,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {ReloadFiletree()ReloadProtyle(rootID)- msg := fmt.Sprintf(Conf.Language(286), destPath)- if box := Conf.GetBox(boxID); nil != box {- msg = fmt.Sprintf(Conf.Language(286), path.Join(box.Name, tree.HPath))- }+ msg := fmt.Sprintf(Conf.Language(286), path.Join(box.Name, tree.HPath))util.PushMsg(msg, 3000)IncSync()@@ -1056,3 +1060,28 @@ func subscribeSQLHistoryEvents() {ReindexHistory()})}++func getRollbackBox(boxID string) (ret *Box, err error) {+ box := Conf.Box(boxID)+ if nil == box {+ boxName := "Rollback"+ box = GetBoxByName(boxName)+ if nil == box {+ var id string+ id, err = CreateBox(boxName)+ if nil != err {+ return+ }+ _, err = Mount(id)+ if nil != err {+ return+ }+ box = Conf.Box(id)+ }+ }+ if nil == box {+ err = errors.New("can not get or create rollback box")+ return+ }+ return+}diff --git a/kernel/model/mount.go b/kernel/model/mount.goindex 2e15da6077..01831257ac 100644--- a/kernel/model/mount.go+++ b/kernel/model/mount.go@@ -34,6 +34,16 @@ import ("github.com/siyuan-note/siyuan/kernel/util")+func GetBoxByName(name string) (ret *Box) {+ for _, box := range Conf.GetOpenedBoxes() {+ if box.Name == name {+ ret = box+ return+ }+ }+ return+}+func CreateBox(name string) (id string, err error) {name = util.RemoveInvalid(name)if 512 < utf8.RuneCountInString(name) {diff --git a/kernel/model/repository.go b/kernel/model/repository.goindex a6f9bae6f4..01832e91f5 100644--- a/kernel/model/repository.go+++ b/kernel/model/repository.go@@ -228,6 +228,15 @@ func RollbackRepoSnapshotFile(fileID string) (err error) {workingDoc := treenode.GetBlockTree(rootID)boxID := strings.TrimPrefix(file.Path, "/")boxID = strings.Split(boxID, "/")[0]++ var box *Box+ box, err = getRollbackBox(boxID)+ if err != nil {+ logging.LogErrorf("get rollback box [%s] failed: %s", boxID, err)+ return+ }+ boxID = box.ID+destPath, parentHPath, err = getRollbackDockPath(boxID, file.Path, workingDoc)if err != nil {return