Go to file
Martin Hibdon d482cbd54b Fix attachments in search results
b/11294681
We had some really broken logic about handling search
results.
In IMAP search, we would request, in a single pass,
FLAGS, ENVELOPE, STRUCTURE, and BODY_SANE. BODY_SANE means
the first N bytes of message content, whether it be from
the message text or attachments. This is different from how
sync works: In sync, we get FLAGS and ENVELOPE in one pass,
and in a later pass get STRUCTURE and first body part text
for each message.
If the total size of the message exceeded the maximum limit
for BODY_SANE, then we'd mark the message as partial, which
would cause us to create a dummy attachment in copyMessageToProvider().
This is a weird solution to the problem of POP messages not
being completely loaded, because in POP message body and
attachments can't be requested separately, so the dummy attachment
just signified that we needed to fetch more data.
This system fails completely on IMAP, because just fetching the
rest of the body will not get you the attachments.

But even if that code is disabled, attachments in search results
still didn't work properly. For reasons I don't yet understand,
if we requet both STRUCTURE and BODY_SANE at the same time, either
we don't received the full attachment metadata, or we ignore it, and
only use the attachments whose contents could actually fit in the
limit imposed by BODY_SANE. So attachments that didn't fit,
or didn't completely fit, would either be missing or corrupt
and unretriveable.

So, end result: It's not clear why we were trying to load
BODY_SANE all in one pass, unlike how it works for sync.
In fact, the way sync does it now makes a lot of sense: We
load FLAGS and ENVELOPE data (small) and put the in the DB
immediately so they can be displayed. In the second pass we
load the (potentially large) structure and message body. If this
is the right solution for sync, it's probably the right solution
for search. So now, that's what we do.

There is cleanup I'd like to do post MR1: Some code is duplicated
between sync and search that could be consolidated, but we're in
low risk mode now so I only changed search code.

Change-Id: I11475e290cda04b91f76d38ba952679e8e8964d5
2013-11-06 10:53:07 -08:00
assets Remove empty.html, which isn't used any more. 2010-12-22 11:59:31 -08:00
emailcommon Foreign characters may be letters and digits, but they're not allowed in Uri/Url schemes 2013-10-31 16:39:03 -07:00
emailsync Remove mAmAccount from the email provider account object 2013-10-04 10:21:25 -07:00
res Update messaging when autodiscover fails due to an auth error 2013-11-05 16:14:56 -08:00
src/com Fix attachments in search results 2013-11-06 10:53:07 -08:00
tests Foreign characters may be letters and digits, but they're not allowed in Uri/Url schemes 2013-10-31 16:39:03 -07:00
.classpath
.project
Android.mk Fix resource overlay order for AOSP Email 2013-10-17 12:07:22 -07:00
AndroidManifest.xml Add permission required for eml viewer to save attachments 2013-11-04 11:53:33 -08:00
CleanSpec.mk Remove unused resource directories 2013-09-06 10:23:02 -07:00
MODULE_LICENSE_APACHE2 auto import from //depot/cupcake/@135843 2009-03-03 19:32:22 -08:00
NOTICE auto import from //depot/cupcake/@135843 2009-03-03 19:32:22 -08:00
proguard.flags Remove nonexistant classes and update existing ones 2013-01-30 14:20:58 -08:00