Only cache attachment items that include size.

This commit is contained in:
akwizgran
2019-06-18 16:59:12 +01:00
parent f3bbc7179e
commit b6b15fe657
2 changed files with 3 additions and 4 deletions

View File

@@ -119,7 +119,7 @@ class AttachmentCreationTask {
AttachmentItem item =
retriever.getAttachmentItem(header, a, needsSize);
if (item.hasError()) throw new IOException();
retriever.cachePut(item);
if (needsSize) retriever.cachePut(item);
return new AttachmentItemResult(uri, item);
} catch (DbException | IOException e) {
logException(LOG, WARNING, e);

View File

@@ -545,6 +545,8 @@ public class ConversationActivity extends BriarActivity
// TODO move getting the items off to IoExecutor, if size == 1
List<AttachmentItem> items =
attachmentRetriever.getAttachmentItems(attachments);
if (items.size() == 1)
attachmentRetriever.cachePut(items.get(0));
displayMessageAttachments(messageId, items);
} catch (DbException e) {
logException(LOG, WARNING, e);
@@ -555,9 +557,6 @@ public class ConversationActivity extends BriarActivity
private void displayMessageAttachments(MessageId m,
List<AttachmentItem> items) {
runOnUiThreadUnlessDestroyed(() -> {
for (AttachmentItem item : items) {
attachmentRetriever.cachePut(item);
}
Pair<Integer, ConversationMessageItem> pair =
adapter.getMessageItem(m);
if (pair != null) {