mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 数据历史文档和资源文件支持分页和搜索 https://github.com/siyuan-note/siyuan/issues/4901
This commit is contained in:
parent
9c4aac7096
commit
61f7f717f7
3 changed files with 34 additions and 1 deletions
|
|
@ -38,7 +38,10 @@ import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var db *sql.DB
|
var (
|
||||||
|
db *sql.DB
|
||||||
|
historyDB *sql.DB
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
regex := func(re, s string) (bool, error) {
|
regex := func(re, s string) (bool, error) {
|
||||||
|
|
@ -141,6 +144,12 @@ func initDBTables() {
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.LogFatalf("create table [refs] failed: %s", 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() {
|
func IndexMode() {
|
||||||
|
|
@ -192,6 +201,27 @@ func initDBConnection() {
|
||||||
db.SetMaxIdleConns(20)
|
db.SetMaxIdleConns(20)
|
||||||
db.SetMaxOpenConns(20)
|
db.SetMaxOpenConns(20)
|
||||||
db.SetConnMaxLifetime(365 * 24 * time.Hour)
|
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) {
|
func SetCaseSensitive(b bool) {
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,7 @@ var (
|
||||||
LogPath string // 配置目录下的日志文件 siyuan.log 路径
|
LogPath string // 配置目录下的日志文件 siyuan.log 路径
|
||||||
DBName = "siyuan.db" // SQLite 数据库文件名
|
DBName = "siyuan.db" // SQLite 数据库文件名
|
||||||
DBPath string // SQLite 数据库文件路径
|
DBPath string // SQLite 数据库文件路径
|
||||||
|
HistoryDBPath string // SQLite 历史数据库文件路径
|
||||||
BlockTreePath string // 区块树文件路径
|
BlockTreePath string // 区块树文件路径
|
||||||
AppearancePath string // 配置目录下的外观目录 appearance/ 路径
|
AppearancePath string // 配置目录下的外观目录 appearance/ 路径
|
||||||
ThemesPath string // 配置目录下的外观目录下的 themes/ 路径
|
ThemesPath string // 配置目录下的外观目录下的 themes/ 路径
|
||||||
|
|
@ -271,6 +272,7 @@ func initWorkspaceDir(workspaceArg string) {
|
||||||
os.Setenv("TEMP", osTmpDir)
|
os.Setenv("TEMP", osTmpDir)
|
||||||
os.Setenv("TMP", osTmpDir)
|
os.Setenv("TMP", osTmpDir)
|
||||||
DBPath = filepath.Join(TempDir, DBName)
|
DBPath = filepath.Join(TempDir, DBName)
|
||||||
|
HistoryDBPath = filepath.Join(TempDir, "history.db")
|
||||||
BlockTreePath = filepath.Join(TempDir, "blocktree.msgpack")
|
BlockTreePath = filepath.Join(TempDir, "blocktree.msgpack")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ func BootMobile(container, appDir, workspaceDir, nativeLibDir, privateDataDir, l
|
||||||
os.RemoveAll(filepath.Join(TempDir, "repo"))
|
os.RemoveAll(filepath.Join(TempDir, "repo"))
|
||||||
os.Setenv("TMPDIR", osTmpDir)
|
os.Setenv("TMPDIR", osTmpDir)
|
||||||
DBPath = filepath.Join(TempDir, DBName)
|
DBPath = filepath.Join(TempDir, DBName)
|
||||||
|
HistoryDBPath = filepath.Join(TempDir, "history.db")
|
||||||
BlockTreePath = filepath.Join(TempDir, "blocktree.msgpack")
|
BlockTreePath = filepath.Join(TempDir, "blocktree.msgpack")
|
||||||
AndroidNativeLibDir = nativeLibDir
|
AndroidNativeLibDir = nativeLibDir
|
||||||
AndroidPrivateDataDir = privateDataDir
|
AndroidPrivateDataDir = privateDataDir
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue