Minor improvements

sync2
Laurent 9 months ago
parent d1091b926e
commit a3f6ad618e
  1. 6
      LeStorage/ApiCallCollection.swift
  2. 2
      LeStorage/StoredCollection+Sync.swift

@ -199,7 +199,7 @@ actor ApiCallCollection<T: SyncedStorable>: SomeCallCollection {
if T.copyServerResponse {
StoreCenter.main.updateLocalInstances(results)
}
self._attemptLoops = -1
// self._attemptLoops = -1
}
} catch {
Logger.error(error)
@ -217,8 +217,12 @@ actor ApiCallCollection<T: SyncedStorable>: SomeCallCollection {
/// Wait for an exponentionnaly long time depending on the number of attemps
fileprivate func _wait() async {
#if DEBUG
let seconds = 2 * self._attemptLoops
#else
let delay = pow(2, self._attemptLoops)
let seconds = NSDecimalNumber(decimal: delay).intValue
#endif
Logger.log("\(T.resourceName()): wait for \(seconds) sec")
do {
try await Task.sleep(until: .now + .seconds(seconds))

@ -276,7 +276,7 @@ extension StoredCollection: SomeSyncedCollection where T : SyncedStorable {
if instance.lastUpdate > localInstance.lastUpdate {
self.updateItem(instance, index: index)
} else {
Logger.log("dont update: \(instance.lastUpdate.timeIntervalSince1970) / \(localInstance.lastUpdate.timeIntervalSince1970)")
Logger.log("do not update: \(instance.lastUpdate.timeIntervalSince1970) / local: \(localInstance.lastUpdate.timeIntervalSince1970)")
}
} else { // insert
if shared {

Loading…
Cancel
Save