🎨 自动校验索引时排除非 id 格式的 .sy 文件 Fix https://github.com/siyuan-note/siyuan/issues/7111

This commit is contained in:
Liang Ding 2023-01-18 13:58:03 +08:00
parent 519f015498
commit c87bb94a60
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 23 additions and 0 deletions

View file

@ -501,6 +501,8 @@ func InitRepoKey() (err error) {
return
}
var isCheckoutRepo bool
func CheckoutRepo(id string) (err error) {
if 1 > len(Conf.Repo.Key) {
err = errors.New(Conf.Language(26))
@ -523,6 +525,16 @@ func CheckoutRepo(id string) (err error) {
Conf.Sync.Enabled = false
Conf.Save()
if util.IsMutexLocked(&syncLock) {
err = errors.New("Sync is running, please try again later")
return
}
isCheckoutRepo = true
defer func() {
isCheckoutRepo = false
}()
_, _, err = repo.Checkout(id, map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
if nil != err {
util.PushClearProgress()

View file

@ -1244,6 +1244,11 @@ func autoFixIndex() {
return
}
if isCheckoutRepo {
logging.LogInfof("skip check index caused by checkout repo")
return
}
if util.IsMutexLocked(&autoFixLock) {
return
}
@ -1286,6 +1291,12 @@ func autoFixIndex() {
break
}
id := path.Base(p)
id = strings.TrimSuffix(id, ".sy")
if !ast.IsNodeIDPattern(id) {
continue
}
reindexTreeByPath(box.ID, p, i, size)
}
}