Refactoring

pull/167/head
M66B 6 years ago
parent d6525eaa68
commit 071ad5f85a

@ -1971,32 +1971,33 @@ class Core {
return _synchronizeMessage(context, account, folder, uid, istore, imessage, browsed, download, rules, state); return _synchronizeMessage(context, account, folder, uid, istore, imessage, browsed, download, rules, state);
} catch (MessagingException ex) { } catch (MessagingException ex) {
// https://javaee.github.io/javamail/FAQ#imapserverbug // https://javaee.github.io/javamail/FAQ#imapserverbug
if (MessageHelper.retryRaw(ex)) try { if (MessageHelper.retryRaw(ex))
Log.w(folder.name + " " + ex.getMessage()); try {
Log.w(folder.name + " " + ex.getMessage());
Log.i(folder.name + " fetching raw message uid=" + uid); Log.i(folder.name + " fetching raw message uid=" + uid);
File file = File.createTempFile("serverbug." + folder.id, "." + uid, context.getCacheDir()); File file = File.createTempFile("serverbug." + folder.id, "." + uid, context.getCacheDir());
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
imessage.writeTo(os); imessage.writeTo(os);
} }
Properties props = MessageHelper.getSessionProperties(); Properties props = MessageHelper.getSessionProperties();
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
Log.i(folder.name + " decoding again uid=" + uid); Log.i(folder.name + " decoding again uid=" + uid);
try (InputStream is = new BufferedInputStream(new FileInputStream(file))) { try (InputStream is = new BufferedInputStream(new FileInputStream(file))) {
imessage = new MimeMessageEx(isession, is, imessage); imessage = new MimeMessageEx(isession, is, imessage);
} }
file.delete(); file.delete();
Log.i(folder.name + " synchronizing again uid=" + uid); Log.i(folder.name + " synchronizing again uid=" + uid);
return _synchronizeMessage(context, account, folder, uid, istore, imessage, browsed, download, rules, state); return _synchronizeMessage(context, account, folder, uid, istore, imessage, browsed, download, rules, state);
} catch (MessagingException ex1) { } catch (MessagingException ex1) {
if (MessageHelper.retryRaw(ex1)) if (MessageHelper.retryRaw(ex1))
Log.e(ex1); Log.e(ex1);
throw ex1; throw ex1;
} }
throw ex; throw ex;
} }

Loading…
Cancel
Save