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: Flashcards are not allowed to be modified during data sync to avoid data overwriting https://github.com/siyuan-note/siyuan/issues/10167
Daniel651f245662b2
diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.goindex bf1693aa19..711e155ae6 100644--- a/kernel/model/flashcard.go+++ b/kernel/model/flashcard.go@@ -641,7 +641,7 @@ func (tx *Transaction) doRemoveFlashcards(operation *Operation) (ret *TxErr) {deckLock.Lock()defer deckLock.Unlock()- if isSyncing.Load() {+ if isSyncingStorages() {ret = &TxErr{code: TxErrCodeDataIsSyncing}return}@@ -753,7 +753,7 @@ func (tx *Transaction) doAddFlashcards(operation *Operation) (ret *TxErr) {deckLock.Lock()defer deckLock.Unlock()- if isSyncing.Load() {+ if isSyncingStorages() {ret = &TxErr{code: TxErrCodeDataIsSyncing}return}diff --git a/kernel/model/repository.go b/kernel/model/repository.goindex 0c54bbc867..ad0959d620 100644--- a/kernel/model/repository.go+++ b/kernel/model/repository.go@@ -955,11 +955,15 @@ var syncingFiles = sync.Map{}var syncingStorages = atomic.Bool{}func waitForSyncingStorages() {- for syncingStorages.Load() {+ for isSyncingStorages() {time.Sleep(time.Second)}}+func isSyncingStorages() bool {+ return syncingStorages.Load() || isBootSyncing.Load()+}+func IsSyncingFile(rootID string) (ret bool) {_, ret = syncingFiles.Load(rootID)return@@ -1105,6 +1109,8 @@ func syncRepoUpload() (err error) {return}+var isBootSyncing = atomic.Bool{}+func bootSyncRepo() (err error) {if 1 > len(Conf.Repo.Key) {autoSyncErrCount++@@ -1129,11 +1135,14 @@ func bootSyncRepo() (err error) {return}+ isBootSyncing.Store(true)+start := time.Now()_, _, err = indexRepoBeforeCloudSync(repo)if nil != err {autoSyncErrCount++planSyncAfter(fixSyncInterval)+ isBootSyncing.Store(false)return}@@ -1180,17 +1189,21 @@ func bootSyncRepo() (err error) {util.PushStatusBar(msg)util.PushErrMsg(msg, 0)BootSyncSucc = 1+ isBootSyncing.Store(false)return}if 0 < len(fetchedFiles) {go func() {_, syncErr := syncRepo(false, false)+ isBootSyncing.Store(false)if nil != err {logging.LogErrorf("boot background sync repo failed: %s", syncErr)return}}()+ } else {+ isBootSyncing.Store(false)}return}