From 431809f1643c5b5bc178cca90dd293c388d1831d Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 11 Mar 2020 13:22:03 +0100 Subject: [PATCH] Reset folder sync state on long wait --- .../java/eu/faircode/email/ServiceSynchronize.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 6e6bd7d947..e13c64a1d1 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1521,16 +1521,15 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences // Cancel transient sync operations boolean enabled = prefs.getBoolean("enabled", true); int pollInterval = prefs.getInt("poll_interval", DEFAULT_POLL_INTERVAL); - if (!enabled || account.ondemand || (pollInterval > 0 && !account.poll_exempted)) { - List syncs = db.operation().getOperations(account.id, EntityOperation.SYNC); - if (syncs != null) { - for (EntityOperation op : syncs) { - db.folder().setFolderSyncState(op.folder, null); + List syncs = db.operation().getOperations(account.id, EntityOperation.SYNC); + if (syncs != null) + for (EntityOperation op : syncs) { + db.folder().setFolderSyncState(op.folder, null); + if (!enabled || account.ondemand || (pollInterval > 0 && !account.poll_exempted)) { db.operation().deleteOperation(op.id); + Log.i(account.name + " cancelled sync folder=" + op.folder); } - Log.i(account.name + " cancelled syncs=" + syncs.size()); } - } // Long back-off period, let device sleep Intent intent = new Intent(ServiceSynchronize.this, ServiceSynchronize.class);