Merge "Don't bail out of downloading an attachment if the size is delcared as zero" into jb-ub-mail-ur10

This commit is contained in:
Tony Mantler 2013-10-17 18:07:45 +00:00 committed by Android (Google) Code Review
commit 164677131a
1 changed files with 7 additions and 2 deletions

View File

@ -740,7 +740,7 @@ class ImapFolder extends Folder {
InputStream bodyStream = body.getAsStream();
message.parse(bodyStream);
}
if (fetchPart != null && fetchPart.getSize() > 0) {
if (fetchPart != null) {
InputStream bodyStream =
fetchList.getKeyedStringOrEmpty("BODY[", true).getAsStream();
String encodings[] = fetchPart.getHeader(
@ -801,7 +801,12 @@ class ImapFolder extends Folder {
out.write(buffer, 0, n);
count += n;
if (listener != null) {
listener.loadAttachmentProgress(count * 100 / size);
if (size == 0) {
// We don't know how big the file is, so just fake it.
listener.loadAttachmentProgress((int)Math.ceil(100 * (1-1.0/count)));
} else {
listener.loadAttachmentProgress(count * 100 / size);
}
}
}
} catch (Base64DataException bde) {