Commit b9f629f6 authored by Ricki Hirner's avatar Ricki Hirner

Collection sync: don't reset "present remotely" flag after enumerating resources

parent c6e37fcc
Pipeline #23668457 passed with stages
in 8 minutes and 46 seconds
......@@ -143,24 +143,27 @@ abstract class SyncManager<out ResourceType: LocalResource<*>, out CollectionTyp
var initialSync = false
var syncState = localCollection.lastSyncState?.takeIf { it.type == SyncState.Type.SYNC_TOKEN }
if (syncState == null) {
Logger.log.info("Starting initial sync")
initialSync = true
resetPresentRemotely()
}
Logger.log.info("Listing changes since $syncState")
var changes: RemoteChanges? = try {
listRemoteChanges(syncState)
} catch(e: HttpException) {
if (e.errors.contains(Property.Name(XmlUtils.NS_WEBDAV, "valid-sync-token"))) {
Logger.log.info("Sync token stale, retrying without sync-token")
Logger.log.info("Sync token invalid, retrying from scratch without sync-token")
syncState = null
initialSync = true
resetPresentRemotely()
listRemoteChanges(null)
} else
throw e
}
if (syncState == null) {
Logger.log.info("Starting initial sync")
initialSync = true
resetPresentRemotely()
}
if (syncState?.initialSync == true) {
Logger.log.info("Continuing initial sync")
initialSync = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment