From 781bcd28d3091b25caf432fb89b05ba0703601f1 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 22 Jun 2021 11:39:39 -0300 Subject: [PATCH] Remove storage snapshots from list if we can't decrypt them --- .../java/org/calyxos/backup/storage/restore/Restore.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt index 819058d3..1bd0e081 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/restore/Restore.kt @@ -68,10 +68,14 @@ internal class Restore( snapshot = snapshotRetriever.getSnapshot(streamKey, oldItem.storedSnapshot) ) } catch (e: Exception) { - Log.e("TAG", "Error retrieving snapshot ${oldItem.time}", e) - continue + Log.e("TAG", "Error retrieving snapshot X ${oldItem.time}", e) + null + } + if (item == null) { + iterator.remove() // remove the failing item from the list + } else { + iterator.set(item) // replace old item with new item } - iterator.set(item) emit(SnapshotResult.Success(ArrayList(list))) } }