Add some comments to storage Restore
This commit is contained in:
parent
18013c0379
commit
d7f985ba8a
1 changed files with 3 additions and 2 deletions
|
@ -26,7 +26,6 @@ import kotlin.time.ExperimentalTime
|
||||||
|
|
||||||
private const val TAG = "Restore"
|
private const val TAG = "Restore"
|
||||||
|
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
|
||||||
internal class Restore(
|
internal class Restore(
|
||||||
context: Context,
|
context: Context,
|
||||||
private val storagePlugin: StoragePlugin,
|
private val storagePlugin: StoragePlugin,
|
||||||
|
@ -57,14 +56,15 @@ internal class Restore(
|
||||||
MultiChunkRestore(context, storagePlugin, fileRestore, streamCrypto, streamKey)
|
MultiChunkRestore(context, storagePlugin, fileRestore, streamCrypto, streamKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
fun getBackupSnapshots(): Flow<SnapshotResult> = flow {
|
fun getBackupSnapshots(): Flow<SnapshotResult> = flow {
|
||||||
val numSnapshots: Int
|
val numSnapshots: Int
|
||||||
val time = measure {
|
val time = measure {
|
||||||
val list = try {
|
val list = try {
|
||||||
|
// get all available backups, they may not be usable
|
||||||
storagePlugin.getBackupSnapshotsForRestore().sortedByDescending { storedSnapshot ->
|
storagePlugin.getBackupSnapshotsForRestore().sortedByDescending { storedSnapshot ->
|
||||||
storedSnapshot.timestamp
|
storedSnapshot.timestamp
|
||||||
}.map { storedSnapshot ->
|
}.map { storedSnapshot ->
|
||||||
|
// as long as snapshot is null, it can't be used for restore
|
||||||
SnapshotItem(storedSnapshot, null)
|
SnapshotItem(storedSnapshot, null)
|
||||||
}.toMutableList()
|
}.toMutableList()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -74,6 +74,7 @@ internal class Restore(
|
||||||
}
|
}
|
||||||
// return list copies, so this works with ListAdapter and DiffUtils
|
// return list copies, so this works with ListAdapter and DiffUtils
|
||||||
emit(SnapshotResult.Success(ArrayList(list)))
|
emit(SnapshotResult.Success(ArrayList(list)))
|
||||||
|
// try to decrypt snapshots and replace list items, if we can decrypt, otherwise remove
|
||||||
numSnapshots = list.size
|
numSnapshots = list.size
|
||||||
val iterator = list.listIterator()
|
val iterator = list.listIterator()
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
|
Loading…
Reference in a new issue