Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 支持列出和切换最近打开的文档 https://github.com/siyuan-note/siyuan/issues/3293

Liang Dingd679bedd773e
diff --git a/kernel/model/storage.go b/kernel/model/storage.go
index cf6252baec..0851989e47 100644
--- a/kernel/model/storage.go
+++ b/kernel/model/storage.go
@@ -17,14 +17,15 @@
package model
import (
- "github.com/88250/lute/parse"
"os"
"path/filepath"
"sync"
"github.com/88250/gulu"
+ "github.com/88250/lute/parse"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
+ "github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
@@ -127,7 +128,7 @@ func setRecentDocs(recentDocs []*RecentDoc) (err error) {
}
func getRecentDocs() (ret []*RecentDoc, err error) {
- ret = []*RecentDoc{}
+ tmp := []*RecentDoc{}
dataPath := filepath.Join(util.DataDir, "storage/recent-doc.json")
if !gulu.File.IsExist(dataPath) {
return
@@ -139,10 +140,22 @@ func getRecentDocs() (ret []*RecentDoc, err error) {
return
}
- if err = gulu.JSON.UnmarshalJSON(data, &ret); nil != err {
+ if err = gulu.JSON.UnmarshalJSON(data, &tmp); nil != err {
logging.LogErrorf("unmarshal storage [recent-doc] failed: %s", err)
return
}
+
+ var notExists []string
+ for _, doc := range tmp {
+ if nil != treenode.GetBlockTree(doc.RootID) {
+ ret = append(ret, doc)
+ } else {
+ notExists = append(notExists, doc.RootID)
+ }
+ }
+ if 0 < len(notExists) {
+ setRecentDocs(ret)
+ }
return
}