Skip to content
Snippets Groups Projects
Commit 7b8dcaea authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Create CrustBackupData, a BackupSnapshot implementation

parent 749372bd
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import io.xxlabs.messenger.backup.cloud.CloudStorage
import io.xxlabs.messenger.backup.data.backup.BackupPreferencesRepository
import io.xxlabs.messenger.backup.data.restore.RestoreEnvironment
import io.xxlabs.messenger.backup.model.BackupLocation
import io.xxlabs.messenger.backup.model.BackupSnapshot
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
......@@ -49,8 +50,10 @@ class Crust private constructor(
}
private suspend fun fetchData() {
cachedBackupData = crustApi.recoverBackup("").getOrNull()?.let {
cachedBackupData = crustApi.recoverBackup(preferences.name).getOrNull()?.let {
AccountArchive(it)
}?.also {
updateLastBackup(CrustBackupData.from(it))
}
}
......@@ -90,3 +93,13 @@ class Crust private constructor(
): Crust = instance ?: Crust(backupService, preferences, crustApi)
}
}
private class CrustBackupData(
override val sizeBytes: Long,
override val date: Long = System.currentTimeMillis()
) : BackupSnapshot {
companion object Factory {
fun from(backupData: AccountArchive) = CrustBackupData(backupData.data.size.toLong())
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment