Log backup verify failure independently from file not found.

This commit is contained in:
Cody Henthorne
2022-11-30 13:22:20 -05:00
parent 979f87db78
commit e5d196c642
2 changed files with 7 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ object BackupVerifier {
private val TAG = Log.tag(BackupVerifier::class.java) private val TAG = Log.tag(BackupVerifier::class.java)
@JvmStatic @JvmStatic
@Throws(IOException::class)
fun verifyFile(cipherStream: InputStream, passphrase: String, expectedCount: Long): Boolean { fun verifyFile(cipherStream: InputStream, passphrase: String, expectedCount: Long): Boolean {
val inputStream = BackupRecordInputStream(cipherStream, passphrase) val inputStream = BackupRecordInputStream(cipherStream, passphrase)

View File

@@ -197,7 +197,12 @@ public final class LocalBackupJobApi29 extends BaseJob {
ThreadUtil.sleep(WAIT_FOR_SCOPED_STORAGE[attempts]); ThreadUtil.sleep(WAIT_FOR_SCOPED_STORAGE[attempts]);
try (InputStream cipherStream = context.getContentResolver().openInputStream(temporaryFile.getUri())) { try (InputStream cipherStream = context.getContentResolver().openInputStream(temporaryFile.getUri())) {
valid = BackupVerifier.verifyFile(cipherStream, backupPassword, finishedEvent.getCount()); try {
valid = BackupVerifier.verifyFile(cipherStream, backupPassword, finishedEvent.getCount());
} catch (IOException e) {
Log.w(TAG, "Unable to verify backup", e);
valid = false;
}
} catch (IOException e) { } catch (IOException e) {
attempts++; attempts++;
Log.w(TAG, "Unable to find backup file, attempt: " + attempts + "/" + MAX_STORAGE_ATTEMPTS); Log.w(TAG, "Unable to find backup file, attempt: " + attempts + "/" + MAX_STORAGE_ATTEMPTS);