From 777aa6d52559493107ef3e6596b9a4e7ac056560 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 3 Jul 2024 12:03:07 -0300 Subject: [PATCH] don't create empty snapshots --- .../src/main/java/org/calyxos/backup/storage/backup/Backup.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/lib/src/main/java/org/calyxos/backup/storage/backup/Backup.kt b/storage/lib/src/main/java/org/calyxos/backup/storage/backup/Backup.kt index 167f78f5..545353ab 100644 --- a/storage/lib/src/main/java/org/calyxos/backup/storage/backup/Backup.kt +++ b/storage/lib/src/main/java/org/calyxos/backup/storage/backup/Backup.kt @@ -33,6 +33,8 @@ internal class BackupResult( backupMediaFiles = backupMediaFiles + other.backupMediaFiles, backupDocumentFiles = backupDocumentFiles + other.backupDocumentFiles, ) + + val isEmpty: Boolean = backupMediaFiles.isEmpty() && backupDocumentFiles.isEmpty() } internal class Backup( @@ -134,6 +136,7 @@ internal class Backup( fileBackup.backupFiles(filesResult.files, availableChunkIds, backupObserver) } val result = largeResult + smallResult + if (result.isEmpty) return // TODO maybe warn user that nothing could get backed up? val backupSize = result.backupMediaFiles.sumOf { it.size } + result.backupDocumentFiles.sumOf { it.size } val endTime = System.currentTimeMillis()