From 919c3efe1cd83376c770a7e9c999f3488a5d0ac5 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 18 Feb 2022 18:44:09 +0100 Subject: [PATCH] Small MODSEQ improvements --- app/src/main/java/eu/faircode/email/Core.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index ca32134f15..93e0e6e5ff 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -3148,9 +3148,12 @@ class Core { try { if (MessageHelper.hasCapability(ifolder, "CONDSTORE")) { modseq = ifolder.getHighestModSeq(); - modified = (force || initialize != 0 || modseq < 0 || + if (modseq < 0) + modseq = null; + modified = (force || initialize != 0 || folder.modseq == null || !folder.modseq.equals(modseq)); - EntityLog.log(context, folder.name + " modseq=" + modseq + "/" + folder.modseq + " modified=" + modified); + EntityLog.log(context, folder.name + " modseq=" + modseq + "/" + folder.modseq + + " force=" + force + " init=" + (initialize != 0) + " modified=" + modified); } } catch (MessagingException ex) { Log.w(folder.name, ex); @@ -3277,7 +3280,7 @@ class Core { else Log.w(ex); modified = true; - db.folder().setFolderModSeq(folder.id, null); + modseq = null; } if (uids.size() > 0) { @@ -3330,6 +3333,7 @@ class Core { throw ex; } catch (Throwable ex) { Log.e(folder.name, ex); + modseq = null; EntityLog.log(context, folder.name + " expunge " + Log.formatThrowable(ex, false)); db.folder().setFolderError(folder.id, Log.formatThrowable(ex)); } @@ -3566,11 +3570,13 @@ class Core { } catch (IOException ex) { if (ex.getCause() instanceof MessagingException) { Log.w(folder.name, ex); + modseq = null; db.folder().setFolderError(folder.id, Log.formatThrowable(ex)); } else throw ex; } catch (Throwable ex) { Log.e(folder.name, ex); + modseq = null; db.folder().setFolderError(folder.id, Log.formatThrowable(ex)); } finally { // Free memory @@ -3611,6 +3617,7 @@ class Core { // Update modseq folder.modseq = modseq; + Log.i(folder.name + " set modseq=" + modseq); db.folder().setFolderModSeq(folder.id, folder.modseq); // Update stats