From 865139b5a3a204a54f0ac6cc09de4530df0c566f Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 7 Oct 2020 07:38:22 +0200 Subject: [PATCH] Fixed swapping sync operations --- app/src/main/java/eu/faircode/email/Core.java | 3 +++ app/src/main/java/eu/faircode/email/TupleOperationEx.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index e0ed73b2be..fa36aedd44 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -174,6 +174,9 @@ class Core { " group=" + group + " retry=" + retry); + if (!Objects.equals(folder.id, op.folder)) + throw new IllegalArgumentException("Invalid folder=" + folder.id + "/" + op.folder); + if (ifolder != null && !ifolder.isOpen()) break; diff --git a/app/src/main/java/eu/faircode/email/TupleOperationEx.java b/app/src/main/java/eu/faircode/email/TupleOperationEx.java index 389fc79825..8d4c25ff5b 100644 --- a/app/src/main/java/eu/faircode/email/TupleOperationEx.java +++ b/app/src/main/java/eu/faircode/email/TupleOperationEx.java @@ -48,6 +48,7 @@ public class TupleOperationEx extends EntityOperation { PartitionKey getPartitionKey(boolean offline) { PartitionKey key = new PartitionKey(); + key.folder = this.folder; key.order = this.id; if (offline) { @@ -77,6 +78,7 @@ public class TupleOperationEx extends EntityOperation { } class PartitionKey { + private long folder; private long order; private int priority; private String id; @@ -99,7 +101,8 @@ public class TupleOperationEx extends EntityOperation { public boolean equals(@Nullable Object obj) { if (obj instanceof PartitionKey) { PartitionKey other = (PartitionKey) obj; - return (this.priority == other.priority && + return (this.folder == other.folder && + this.priority == other.priority && Objects.equals(this.id, other.id) && Objects.equals(this.operation, other.operation)); } else