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/4901
Liang Ding61f7f717f78c
diff --git a/kernel/sql/database.go b/kernel/sql/database.goindex 6e46160555..2d8d6e18cf 100644--- a/kernel/sql/database.go+++ b/kernel/sql/database.go@@ -38,7 +38,10 @@ import ("github.com/siyuan-note/siyuan/kernel/util")-var db *sql.DB+var (+ db *sql.DB+ historyDB *sql.DB+)func init() {regex := func(re, s string) (bool, error) {@@ -141,6 +144,12 @@ func initDBTables() {if nil != err {logging.LogFatalf("create table [refs] failed: %s", err)}++ historyDB.Exec("DROP TABLE history_fts_case_insensitive")+ _, err = db.Exec("CREATE VIRTUAL TABLE history_fts_case_insensitive USING fts5(type UNINDEXED, op UNINDEXED, title, content, created UNINDEXED, path UNINDEXED, tokenize=\"siyuan case_insensitive\")")+ if nil != err {+ logging.LogFatalf("create table [history_fts_case_insensitive] failed: %s", err)+ }}func IndexMode() {@@ -192,6 +201,27 @@ func initDBConnection() {db.SetMaxIdleConns(20)db.SetMaxOpenConns(20)db.SetConnMaxLifetime(365 * 24 * time.Hour)++ if nil != historyDB {+ historyDB.Close()+ }+ dsn = util.HistoryDBPath + "?_journal_mode=OFF" ++ "&_synchronous=OFF" ++ "&_secure_delete=OFF" ++ "&_cache_size=-20480" ++ "&_page_size=8192" ++ "&_busy_timeout=7000" ++ "&_ignore_check_constraints=ON" ++ "&_temp_store=MEMORY" ++ "&_case_sensitive_like=OFF" ++ "&_locking_mode=EXCLUSIVE"+ historyDB, err = sql.Open("sqlite3_extended", dsn)+ if nil != err {+ logging.LogFatalf("create database failed: %s", err)+ }+ historyDB.SetMaxIdleConns(1)+ historyDB.SetMaxOpenConns(1)+ historyDB.SetConnMaxLifetime(365 * 24 * time.Hour)}func SetCaseSensitive(b bool) {diff --git a/kernel/util/working.go b/kernel/util/working.goindex 1c66e5aaec..fe1c9a6709 100644--- a/kernel/util/working.go+++ b/kernel/util/working.go@@ -168,6 +168,7 @@ var (LogPath string // 配置目录下的日志文件 siyuan.log 路径DBName = "siyuan.db" // SQLite 数据库文件名DBPath string // SQLite 数据库文件路径+ HistoryDBPath string // SQLite 历史数据库文件路径BlockTreePath string // 区块树文件路径AppearancePath string // 配置目录下的外观目录 appearance/ 路径ThemesPath string // 配置目录下的外观目录下的 themes/ 路径@@ -271,6 +272,7 @@ func initWorkspaceDir(workspaceArg string) {os.Setenv("TEMP", osTmpDir)os.Setenv("TMP", osTmpDir)DBPath = filepath.Join(TempDir, DBName)+ HistoryDBPath = filepath.Join(TempDir, "history.db")BlockTreePath = filepath.Join(TempDir, "blocktree.msgpack")}diff --git a/kernel/util/working_mobile.go b/kernel/util/working_mobile.goindex caf753912c..e3beefc9b2 100644--- a/kernel/util/working_mobile.go+++ b/kernel/util/working_mobile.go@@ -51,6 +51,7 @@ func BootMobile(container, appDir, workspaceDir, nativeLibDir, privateDataDir, los.RemoveAll(filepath.Join(TempDir, "repo"))os.Setenv("TMPDIR", osTmpDir)DBPath = filepath.Join(TempDir, DBName)+ HistoryDBPath = filepath.Join(TempDir, "history.db")BlockTreePath = filepath.Join(TempDir, "blocktree.msgpack")AndroidNativeLibDir = nativeLibDirAndroidPrivateDataDir = privateDataDir