Merge pull request #6255 from thundernest/fix_shared_attachment_crash

Don't crash when trying to access attachment (meta) data
This commit is contained in:
cketti 2022-08-29 14:04:36 +02:00 committed by GitHub
commit 1de1f54518
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 46 deletions

View file

@ -3,7 +3,6 @@ package com.fsck.k9.activity.loader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import android.content.ContentResolver;
@ -88,7 +87,7 @@ public class AttachmentContentLoader extends AsyncTaskLoader<Attachment> {
cachedResultAttachment = sourceAttachment.deriveWithLoadComplete(file.getAbsolutePath());
return cachedResultAttachment;
} catch (IOException e) {
} catch (Exception e) {
Timber.e(e, "Error saving attachment!");
}

View file

@ -46,6 +46,7 @@ public class AttachmentInfoLoader extends AsyncTaskLoader<Attachment> {
@Override
public Attachment loadInBackground() {
try {
Uri uri = sourceAttachment.uri;
String contentType = sourceAttachment.contentType;
@ -104,5 +105,11 @@ public class AttachmentInfoLoader extends AsyncTaskLoader<Attachment> {
cachedResultAttachment = sourceAttachment.deriveWithMetadataLoaded(usableContentType, name, size);
return cachedResultAttachment;
} catch (Exception e) {
Timber.e(e, "Error getting attachment meta data");
cachedResultAttachment = sourceAttachment.deriveWithLoadCancelled();
return cachedResultAttachment;
}
}
}