From 51a7433dfd70053a7fe3d8531a42a916d7579be7 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 16 Oct 2018 12:25:21 +0000 Subject: [PATCH] Synchronize selectable folders only --- .../eu/faircode/email/ServiceSynchronize.java | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index bc1ddac6..55c34805 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1436,25 +1436,36 @@ public class ServiceSynchronize extends LifecycleService { Log.i(Helper.TAG, "Remote folder count=" + ifolders.length); for (Folder ifolder : ifolders) { - EntityFolder folder = db.folder().getFolderByName(account.id, ifolder.getFullName()); - if (folder == null) { - folder = new EntityFolder(); - folder.account = account.id; - folder.name = ifolder.getFullName(); - folder.type = EntityFolder.USER; - folder.synchronize = false; - folder.after = EntityFolder.DEFAULT_USER_SYNC; - db.folder().insertFolder(folder); - Log.i(Helper.TAG, folder.name + " added"); - } else { - names.remove(folder.name); - Log.i(Helper.TAG, folder.name + " exists"); + boolean selectable = true; + String[] attrs = ((IMAPFolder) ifolder).getAttributes(); + for (String attr : attrs) { + if ("\\Noselect".equals(attr)) + selectable = false; + } + + if (selectable) { + EntityFolder folder = db.folder().getFolderByName(account.id, ifolder.getFullName()); + if (folder == null) { + folder = new EntityFolder(); + folder.account = account.id; + folder.name = ifolder.getFullName(); + folder.type = EntityFolder.USER; + folder.synchronize = false; + folder.after = EntityFolder.DEFAULT_USER_SYNC; + db.folder().insertFolder(folder); + Log.i(Helper.TAG, folder.name + " added"); + } else { + names.remove(folder.name); + Log.i(Helper.TAG, folder.name + " exists"); + } } } Log.i(Helper.TAG, "Delete local folder=" + names.size()); - for (String name : names) + for (String name : names) { db.folder().deleteFolder(account.id, name); + Log.i(Helper.TAG, name + " deleted"); + } db.setTransactionSuccessful(); } finally {