diff --git a/src/main/java/com/machiav3lli/backup/OABX.kt b/src/main/java/com/machiav3lli/backup/OABX.kt index a2bc264a1..10af1b7ac 100644 --- a/src/main/java/com/machiav3lli/backup/OABX.kt +++ b/src/main/java/com/machiav3lli/backup/OABX.kt @@ -681,13 +681,15 @@ class OABX : Application() { } } - fun setBackups(backups: Map>) { - backups.forEach { - putBackups(it.key, it.value) - } - // clear no more existing packages - (theBackupsMap.keys - backups.keys).forEach { - removeBackups(it) + fun setBackups(backupsMap: Map>) { + synchronized(theBackupsMap) { + backupsMap.forEach { (packageName, backups) -> + theBackupsMap.put(packageName, backups) + } + // clear no more existing packages + (theBackupsMap.keys - backupsMap.keys).forEach { + theBackupsMap.remove(it) + } } } @@ -719,14 +721,18 @@ class OABX : Application() { } fun emptyBackupsForMissingPackages(packageNames: List) { - (packageNames - theBackupsMap.keys).forEach { - putBackups(it, emptyList()) + synchronized(theBackupsMap) { + (packageNames - theBackupsMap.keys).forEach { + theBackupsMap.put(it, emptyList()) + } } } fun emptyBackupsForAllPackages(packageNames: List) { - packageNames.forEach { - putBackups(it, emptyList()) + synchronized(theBackupsMap) { + packageNames.forEach { + theBackupsMap.put(it, emptyList()) + } } }