Skip to content

Commit

Permalink
fix synchronizing backups
Browse files Browse the repository at this point in the history
  • Loading branch information
hg42 committed Oct 26, 2024
1 parent 0ae2261 commit f5bbde9
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/main/java/com/machiav3lli/backup/OABX.kt
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,15 @@ class OABX : Application() {
}
}

fun setBackups(backups: Map<String, List<Backup>>) {
backups.forEach {
putBackups(it.key, it.value)
}
// clear no more existing packages
(theBackupsMap.keys - backups.keys).forEach {
removeBackups(it)
fun setBackups(backupsMap: Map<String, List<Backup>>) {
synchronized(theBackupsMap) {
backupsMap.forEach { (packageName, backups) ->
theBackupsMap.put(packageName, backups)
}
// clear no more existing packages
(theBackupsMap.keys - backupsMap.keys).forEach {
theBackupsMap.remove(it)
}
}
}

Expand Down Expand Up @@ -719,14 +721,18 @@ class OABX : Application() {
}

fun emptyBackupsForMissingPackages(packageNames: List<String>) {
(packageNames - theBackupsMap.keys).forEach {
putBackups(it, emptyList())
synchronized(theBackupsMap) {
(packageNames - theBackupsMap.keys).forEach {
theBackupsMap.put(it, emptyList())
}
}
}

fun emptyBackupsForAllPackages(packageNames: List<String>) {
packageNames.forEach {
putBackups(it, emptyList())
synchronized(theBackupsMap) {
packageNames.forEach {
theBackupsMap.put(it, emptyList())
}
}
}

Expand Down

0 comments on commit f5bbde9

Please sign in to comment.