Commit be2d1027 authored by Ricki Hirner's avatar Ricki Hirner 🐑

Collection sync: don't download already available resources

parent f4b864b3
......@@ -236,8 +236,22 @@ abstract class BaseDavSyncManager<ResourceType: LocalResource<*>, out Collection
}
val changes = RemoteChanges(syncToken?.let { SyncState(SyncState.Type.SYNC_TOKEN, it) }, davCollection.furtherResults)
for (member in davCollection.members)
changes.updated += member
for (member in davCollection.members) {
// ignore if resource is existing locally with same ETag
// (happens at initial sync, when resources are already present locally)
var skip = false
localCollection.findByName(member.fileName())?.let { local ->
member.properties[GetETag::class.java]?.eTag?.let { remoteETag ->
if (local.eTag == remoteETag) {
Logger.log.info("${local.fileName} is already available with ETag $remoteETag, skipping update")
skip = true
}
}
}
if (!skip)
changes.updated += member
}
for (member in davCollection.removedMembers)
changes.deleted += member.fileName()
......
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