mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-03 23:38:49 +01:00
🎨 Flashcards are not allowed to be modified during data sync to avoid data overwriting https://github.com/siyuan-note/siyuan/issues/10167
This commit is contained in:
parent
c3b4aa971d
commit
651f245662
2 changed files with 16 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue