🎨 Automatically loads and indexes from the file system when a block is not found https://github.com/siyuan-note/siyuan/issues/10772

This commit is contained in:
Daniel 2024-03-28 11:35:09 +08:00
parent b3d581718b
commit 50eef7d1e6
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017

View File

@ -181,6 +181,7 @@ func searchTreeInFilesystem(rootID string) {
msdID := util.PushMsg(Conf.language(45), 7000)
defer util.PushClearMsg(msdID)
logging.LogWarnf("searching tree on filesystem [rootID=%s]", rootID)
var treePath string
filepath.Walk(util.DataDir, func(path string, info fs.FileInfo, err error) error {
if info.IsDir() {
@ -204,6 +205,7 @@ func searchTreeInFilesystem(rootID string) {
})
if "" == treePath {
logging.LogErrorf("tree not found on filesystem [rootID=%s]", rootID)
return
}
@ -224,4 +226,5 @@ func searchTreeInFilesystem(rootID string) {
treenode.IndexBlockTree(tree)
sql.IndexTreeQueue(tree)
sql.WaitForWritingDatabase()
logging.LogInfof("reindexed tree by filesystem [rootID=%s]", rootID)
}