Browse Source

Handle message removed exception

main
M66B 6 years ago
parent
commit
8d49b25c6a
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 10
- 1
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -63,6 +63,7 @@ import javax.mail.FetchProfile;
import javax.mail.Flags; import javax.mail.Flags;
import javax.mail.Folder; import javax.mail.Folder;
import javax.mail.Message; import javax.mail.Message;
import javax.mail.MessageRemovedException;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import javax.mail.Session; import javax.mail.Session;
import javax.mail.Transport; import javax.mail.Transport;
@ -392,6 +393,8 @@ public class ServiceSynchronize extends LifecycleService {
Log.i(Helper.TAG, folder.name + " messages added"); Log.i(Helper.TAG, folder.name + " messages added");
for (Message imessage : e.getMessages()) for (Message imessage : e.getMessages())
synchronizeMessage(folder, ffolder, (IMAPMessage) imessage); synchronizeMessage(folder, ffolder, (IMAPMessage) imessage);
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
nm.notify("error", folder.id.intValue(), getNotification(folder.name, ex).build()); nm.notify("error", folder.id.intValue(), getNotification(folder.name, ex).build());
@ -441,6 +444,8 @@ public class ServiceSynchronize extends LifecycleService {
try { try {
Log.i(Helper.TAG, folder.name + " message changed"); Log.i(Helper.TAG, folder.name + " message changed");
synchronizeMessage(folder, ffolder, (IMAPMessage) e.getMessage()); synchronizeMessage(folder, ffolder, (IMAPMessage) e.getMessage());
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
nm.notify("error", folder.id.intValue(), getNotification(folder.name, ex).build()); nm.notify("error", folder.id.intValue(), getNotification(folder.name, ex).build());
@ -812,7 +817,11 @@ public class ServiceSynchronize extends LifecycleService {
try { try {
db.beginTransaction(); db.beginTransaction();
for (int i = 0; i < FETCH_BATCH_SIZE && batch + i < added.size(); i++) for (int i = 0; i < FETCH_BATCH_SIZE && batch + i < added.size(); i++)
synchronizeMessage(folder, ifolder, (IMAPMessage) added.get(batch + i));
try {
synchronizeMessage(folder, ifolder, (IMAPMessage) added.get(batch + i));
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
}
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();


Loading…
Cancel
Save