Skip to content

Commit

Permalink
Syncer: make sure collections which are deleted are not synced
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc2822 committed Oct 9, 2024
1 parent 26a670c commit ba0db9f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/src/main/kotlin/at/bitfire/davdroid/sync/Syncer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,17 @@ abstract class Syncer<CollectionType: LocalCollection<*>>(
*/
@VisibleForTesting
internal fun updateCollections(
localCollections: List<CollectionType>,
localCollections: MutableList<CollectionType>,
dbCollections: Map<HttpUrl, Collection>
): HashMap<HttpUrl, Collection> {
val newDbCollections = HashMap(dbCollections) // create a copy
for (localCollection in localCollections) {
val dbCollection = dbCollections[localCollection.collectionUrl?.toHttpUrlOrNull()]
if (dbCollection == null)
if (dbCollection == null) {
// Collection not available in db = on server (anymore), delete obsolete local collection
localCollection.deleteCollection()
else {
localCollections -= localCollection
} else {
// Collection exists locally, update local collection and remove it from "to be created" map
update(localCollection, dbCollection)
newDbCollections -= dbCollection.url
Expand Down

0 comments on commit ba0db9f

Please sign in to comment.