Synchronized invalidate

pull/194/merge
M66B 3 years ago
parent 79e19036a9
commit 8f7a3d001b

@ -280,9 +280,10 @@ class Core {
case EntityOperation.FETCH:
if (EntityOperation.FETCH.equals(next.name)) {
JSONArray jnext = new JSONArray(next.args);
// Same uid, delete flag
// Same uid, invalidate, delete flag
if (jargs.getLong(0) == jnext.getLong(0) &&
jargs.optBoolean(1) == jnext.optBoolean(1))
jargs.optBoolean(1) == jnext.optBoolean(1) &&
jargs.optBoolean(2) == jnext.optBoolean(2))
skip = true;
}
break;
@ -1568,7 +1569,8 @@ class Core {
private static void onFetch(Context context, JSONArray jargs, EntityFolder folder, IMAPStore istore, IMAPFolder ifolder, State state) throws JSONException, MessagingException, IOException {
long uid = jargs.getLong(0);
boolean removed = jargs.optBoolean(1);
boolean invalidate = jargs.optBoolean(1);
boolean removed = jargs.optBoolean(2);
if (uid < 0)
throw new MessageRemovedException(folder.name + " fetch uid=" + uid);
@ -1589,6 +1591,9 @@ class Core {
throw new MessageRemovedException(folder.name + " fetch not found uid=" + uid);
// synchronizeMessage will check expunged/deleted
if (invalidate && imessage instanceof IMAPMessage)
((IMAPMessage) imessage).invalidateHeaders();
SyncStats stats = new SyncStats();
boolean download = db.folder().getFolderDownload(folder.id);
List<EntityRule> rules = db.rule().getEnabledRules(folder.id);

@ -1618,7 +1618,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
public void messagesAdded(MessageCountEvent e) {
try {
wlMessage.acquire();
fetch(folder, ifolder, e.getMessages(), false, "added");
fetch(folder, ifolder, e.getMessages(), false, false, "added");
Thread.sleep(FETCH_YIELD_DURATION);
} catch (Throwable ex) {
Log.e(folder.name, ex);
@ -1634,7 +1634,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
public void messagesRemoved(MessageCountEvent e) {
try {
wlMessage.acquire();
fetch(folder, ifolder, e.getMessages(), true, "removed");
fetch(folder, ifolder, e.getMessages(), false, true, "removed");
Thread.sleep(FETCH_YIELD_DURATION);
} catch (Throwable ex) {
Log.e(folder.name, ex);
@ -1656,9 +1656,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
try {
wlMessage.acquire();
Message imessage = e.getMessage();
if (imessage instanceof IMAPMessage)
((IMAPMessage) imessage).invalidateHeaders();
fetch(folder, ifolder, new Message[]{imessage}, false, "changed");
fetch(folder, ifolder, new Message[]{imessage}, true, false, "changed");
Thread.sleep(FETCH_YIELD_DURATION);
} catch (Throwable ex) {
Log.e(folder.name, ex);
@ -2367,7 +2365,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
}
}
private void fetch(EntityFolder folder, IMAPFolder ifolder, Message[] messages, boolean deleted, String reason) throws MessagingException {
private void fetch(EntityFolder folder, IMAPFolder ifolder, Message[] messages, boolean invalidate, boolean deleted, String reason) throws MessagingException {
Log.i(folder.name + " " + messages.length + " messages " + reason);
List<Long> uids = new ArrayList<>();
@ -2386,7 +2384,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
db.beginTransaction();
for (long uid : uids)
EntityOperation.queue(this, folder, EntityOperation.FETCH, uid, deleted);
EntityOperation.queue(this, folder, EntityOperation.FETCH, uid, invalidate, deleted);
db.setTransactionSuccessful();
} finally {

Loading…
Cancel
Save