From dbddb274db0171c246e35b4129ef6dade6e89155 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Tue, 17 May 2022 11:00:52 -0400 Subject: [PATCH] Revert "Fix NPE in PartProvider." This reverts commit 3b16a1d28c1c5a66f44b4f648d316d2bf2e4092e. --- .../securesms/providers/PartProvider.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/providers/PartProvider.java b/app/src/main/java/org/thoughtcrime/securesms/providers/PartProvider.java index 3bbe180bce..86c043e26b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/providers/PartProvider.java +++ b/app/src/main/java/org/thoughtcrime/securesms/providers/PartProvider.java @@ -102,7 +102,7 @@ public final class PartProvider extends BaseContentProvider { public String getType(@NonNull Uri uri) { Log.i(TAG, "getType() called: " + uri); - if (uriMatcher.match(uri) == SINGLE_ROW && SignalDatabase.getInstance() != null) { + if (uriMatcher.match(uri) == SINGLE_ROW) { PartUriParser partUriParser = new PartUriParser(uri); DatabaseAttachment attachment = SignalDatabase.attachments().getAttachment(partUriParser.getPartId()); @@ -157,20 +157,9 @@ public final class PartProvider extends BaseContentProvider { ParcelFileDescriptor[] reliablePipe = ParcelFileDescriptor.createReliablePipe(); SignalExecutors.BOUNDED_IO.execute(() -> { - SignalDatabase signalDatabase = SignalDatabase.getInstance(); - if (signalDatabase == null) { - Log.w(TAG, "Database is not available"); - try { - reliablePipe[1].closeWithError("Unable to access database"); - } catch (IOException e) { - Log.w(TAG, "Unable to close pipe after no database", e); - } - return; - } - Throwable error = null; try (OutputStream out = new FileOutputStream(reliablePipe[1].getFileDescriptor())) { - try (InputStream in = signalDatabase.getAttachments().getAttachmentStream(attachmentId, 0)) { + try (InputStream in = SignalDatabase.attachments().getAttachmentStream(attachmentId, 0)) { StreamUtil.copy(in, out); } catch (IOException e) { Log.w(TAG, "Error providing file", e);