|
@@ -955,11 +955,15 @@ var syncingFiles = sync.Map{}
|
|
var syncingStorages = atomic.Bool{}
|
|
var syncingStorages = atomic.Bool{}
|
|
|
|
|
|
func waitForSyncingStorages() {
|
|
func waitForSyncingStorages() {
|
|
- for syncingStorages.Load() {
|
|
|
|
|
|
+ for isSyncingStorages() {
|
|
time.Sleep(time.Second)
|
|
time.Sleep(time.Second)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func isSyncingStorages() bool {
|
|
|
|
+ return syncingStorages.Load() || isBootSyncing.Load()
|
|
|
|
+}
|
|
|
|
+
|
|
func IsSyncingFile(rootID string) (ret bool) {
|
|
func IsSyncingFile(rootID string) (ret bool) {
|
|
_, ret = syncingFiles.Load(rootID)
|
|
_, ret = syncingFiles.Load(rootID)
|
|
return
|
|
return
|
|
@@ -1105,6 +1109,8 @@ func syncRepoUpload() (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+var isBootSyncing = atomic.Bool{}
|
|
|
|
+
|
|
func bootSyncRepo() (err error) {
|
|
func bootSyncRepo() (err error) {
|
|
if 1 > len(Conf.Repo.Key) {
|
|
if 1 > len(Conf.Repo.Key) {
|
|
autoSyncErrCount++
|
|
autoSyncErrCount++
|
|
@@ -1129,11 +1135,14 @@ func bootSyncRepo() (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ isBootSyncing.Store(true)
|
|
|
|
+
|
|
start := time.Now()
|
|
start := time.Now()
|
|
_, _, err = indexRepoBeforeCloudSync(repo)
|
|
_, _, err = indexRepoBeforeCloudSync(repo)
|
|
if nil != err {
|
|
if nil != err {
|
|
autoSyncErrCount++
|
|
autoSyncErrCount++
|
|
planSyncAfter(fixSyncInterval)
|
|
planSyncAfter(fixSyncInterval)
|
|
|
|
+ isBootSyncing.Store(false)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1180,17 +1189,21 @@ func bootSyncRepo() (err error) {
|
|
util.PushStatusBar(msg)
|
|
util.PushStatusBar(msg)
|
|
util.PushErrMsg(msg, 0)
|
|
util.PushErrMsg(msg, 0)
|
|
BootSyncSucc = 1
|
|
BootSyncSucc = 1
|
|
|
|
+ isBootSyncing.Store(false)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
if 0 < len(fetchedFiles) {
|
|
if 0 < len(fetchedFiles) {
|
|
go func() {
|
|
go func() {
|
|
_, syncErr := syncRepo(false, false)
|
|
_, syncErr := syncRepo(false, false)
|
|
|
|
+ isBootSyncing.Store(false)
|
|
if nil != err {
|
|
if nil != err {
|
|
logging.LogErrorf("boot background sync repo failed: %s", syncErr)
|
|
logging.LogErrorf("boot background sync repo failed: %s", syncErr)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
|
|
+ } else {
|
|
|
|
+ isBootSyncing.Store(false)
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|