From 2ac18339439631f2539a4cd35056b8ae65d5a24f Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Thu, 20 Jan 2011 09:47:57 -0800 Subject: [PATCH] Delete attachment if there's no corresponding message Bug: 3372440 Change-Id: I5c3653c5f27e0aa7bab52ca0d979e14bb6bafc34 --- src/com/android/email/Controller.java | 4 ++++ src/com/android/email/service/AttachmentDownloadService.java | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/Controller.java b/src/com/android/email/Controller.java index 63a68a205..8c9ccdfe8 100644 --- a/src/com/android/email/Controller.java +++ b/src/com/android/email/Controller.java @@ -1630,6 +1630,10 @@ public class Controller { LegacyListener legacyListener = sInstance.mLegacyListener; legacyController.loadAttachment(msg.mAccountKey, msg.mId, msg.mMailboxKey, attachmentId, legacyListener); + } else { + // Send back the specific error status for this case + sInstance.mCallbackProxy.loadAttachmentStatus(att.mMessageKey, attachmentId, + EmailServiceStatus.MESSAGE_NOT_FOUND, 0); } } } diff --git a/src/com/android/email/service/AttachmentDownloadService.java b/src/com/android/email/service/AttachmentDownloadService.java index 94c14670c..e6a8473d6 100644 --- a/src/com/android/email/service/AttachmentDownloadService.java +++ b/src/com/android/email/service/AttachmentDownloadService.java @@ -528,7 +528,10 @@ public class AttachmentDownloadService extends Service implements Runnable { MailService.actionSendPendingMail(mContext, req.accountId); } } - if (!deleted) { + if (statusCode == EmailServiceStatus.MESSAGE_NOT_FOUND) { + // If there's no associated message, delete the attachment + EmailContent.delete(mContext, Attachment.CONTENT_URI, attachment.mId); + } else if (!deleted) { // Clear the download flags, since we're done for now. Note that this happens // only for non-recoverable errors. When these occur for forwarded mail, we can // ignore it and continue; otherwise, it was either 1) a user request, in which