From f7964478154bc7df554ba649b99daf141c0d1578 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Tue, 3 Nov 2020 15:23:58 -0400 Subject: [PATCH] Add better error logging for single backup Uris. --- .../thoughtcrime/securesms/util/BackupUtil.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/BackupUtil.java b/app/src/main/java/org/thoughtcrime/securesms/util/BackupUtil.java index eb70647a44..644c07bfa4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/BackupUtil.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/BackupUtil.java @@ -174,6 +174,7 @@ public class BackupUtil { return new BackupInfo(backupTimestamp, documentFile.length(), documentFile.getUri()); } else { + logIssueWithDocumentFile(documentFile); Log.w(TAG, "Could not load backup info."); return null; } @@ -259,6 +260,20 @@ public class BackupUtil { return -1; } + private static void logIssueWithDocumentFile(@Nullable DocumentFile documentFile) { + if (documentFile == null) { + throw new AssertionError("We do not support platforms prior to KitKat."); + } else if (!documentFile.exists()) { + Log.w(TAG, "The document at the specified Uri cannot be found."); + } else if (!documentFile.canRead()) { + Log.w(TAG, "The document at the specified Uri cannot be read."); + } else if (!documentFile.canWrite()) { + Log.w(TAG, "The document at the specified Uri cannot be written to."); + } else if (!documentFile.getName().endsWith(".backup")) { + Log.w(TAG, "The document at the specified Uri has an unsupported file extension."); + } + } + public static class BackupInfo { private final long timestamp;