1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-26 09:38:52 -05:00

Merge branch 'MessageListAdapter_cleanup'

This commit is contained in:
cketti 2012-09-09 00:51:45 +02:00
commit 734e0d1920
4 changed files with 440 additions and 354 deletions

File diff suppressed because it is too large Load Diff

View File

@ -85,7 +85,7 @@ public class MessageHelper {
target.uid = message.getUid(); target.uid = message.getUid();
target.account = account.getDescription(); target.account = account.getUuid();
target.uri = "email://messages/" + account.getAccountNumber() + "/" + m.getFolder().getName() + "/" + m.getUid(); target.uri = "email://messages/" + account.getAccountNumber() + "/" + m.getFolder().getName() + "/" + m.getUid();
} catch (MessagingException me) { } catch (MessagingException me) {

View File

@ -45,13 +45,16 @@ public class BinaryTempFileBody implements Body {
public void writeTo(OutputStream out) throws IOException, MessagingException { public void writeTo(OutputStream out) throws IOException, MessagingException {
InputStream in = getInputStream(); InputStream in = getInputStream();
Base64OutputStream base64Out = new Base64OutputStream(out);
try { try {
IOUtils.copy(in, base64Out); Base64OutputStream base64Out = new Base64OutputStream(out);
try {
IOUtils.copy(in, base64Out);
} finally {
base64Out.close();
}
} finally { } finally {
base64Out.close(); in.close();
} }
mFile.delete();
} }
class BinaryTempFileBodyInputStream extends FilterInputStream { class BinaryTempFileBodyInputStream extends FilterInputStream {
@ -61,8 +64,11 @@ public class BinaryTempFileBody implements Body {
@Override @Override
public void close() throws IOException { public void close() throws IOException {
super.close(); try {
mFile.delete(); super.close();
} finally {
mFile.delete();
}
} }
} }
} }

View File

@ -1059,15 +1059,20 @@ public class MimeUtility {
/* /*
* Now we read the part into a buffer for further processing. Because * Now we read the part into a buffer for further processing. Because
* the stream is now wrapped we'll remove any transfer encoding at this point. * the stream is now wrapped we'll remove any transfer encoding at this point.
*
* We can't wrap this in a try-finally to close the InputStream. It looks like
* we depend on the underlying temp file to exist across calls, and closing it
* deletes the file, which isn't what we want. We should figure out if this
* is really the right way to be doing things, since it's triggering strict
* mode warnings.
*/ */
InputStream in = part.getBody().getInputStream(); InputStream in = part.getBody().getInputStream();
return readToString(in, charset); try {
String text = readToString(in, charset);
// Replace the body with a TextBody that already contains the decoded text
part.setBody(new TextBody(text));
return text;
} finally {
try {
in.close();
} catch (IOException e) { /* Ignore */ }
}
} }
} }