mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 数据历史文档和资源文件支持分页和搜索 https://github.com/siyuan-note/siyuan/issues/4901
This commit is contained in:
parent
d31f23e2da
commit
f3b495aff5
3 changed files with 59 additions and 5 deletions
|
|
@ -147,13 +147,27 @@ func initDBTables() {
|
|||
}
|
||||
|
||||
func InitHistoryDatabase(forceRebuild bool) {
|
||||
initHistoryDBConnection()
|
||||
|
||||
if !forceRebuild && gulu.File.IsExist(util.HistoryDBPath) {
|
||||
return
|
||||
}
|
||||
|
||||
historyDB.Close()
|
||||
if err := os.RemoveAll(util.HistoryDBPath); nil != err {
|
||||
logging.LogErrorf("remove history database file [%s] failed: %s", util.HistoryDBPath, err)
|
||||
return
|
||||
}
|
||||
|
||||
initHistoryDBConnection()
|
||||
initHistoryDBTables()
|
||||
}
|
||||
|
||||
func initHistoryDBConnection() {
|
||||
if nil != historyDB {
|
||||
historyDB.Close()
|
||||
}
|
||||
|
||||
dsn := util.HistoryDBPath + "?_journal_mode=OFF" +
|
||||
"&_synchronous=OFF" +
|
||||
"&_secure_delete=OFF" +
|
||||
|
|
@ -172,9 +186,11 @@ func InitHistoryDatabase(forceRebuild bool) {
|
|||
historyDB.SetMaxIdleConns(1)
|
||||
historyDB.SetMaxOpenConns(1)
|
||||
historyDB.SetConnMaxLifetime(365 * 24 * time.Hour)
|
||||
}
|
||||
|
||||
func initHistoryDBTables() {
|
||||
historyDB.Exec("DROP TABLE histories_fts_case_insensitive")
|
||||
_, err = historyDB.Exec("CREATE VIRTUAL TABLE histories_fts_case_insensitive USING fts5(type UNINDEXED, op UNINDEXED, title, content, path UNINDEXED, created UNINDEXED, tokenize=\"siyuan case_insensitive\")")
|
||||
_, err := historyDB.Exec("CREATE VIRTUAL TABLE histories_fts_case_insensitive USING fts5(type UNINDEXED, op UNINDEXED, title, content, path UNINDEXED, created UNINDEXED, tokenize=\"siyuan case_insensitive\")")
|
||||
if nil != err {
|
||||
logging.LogFatalf("create table [histories_fts_case_insensitive] failed: %s", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue