Browse Source

Synchronize selectable folders only

main
M66B 6 years ago
parent
commit
51a7433dfd
1 changed files with 25 additions and 14 deletions
  1. +25
    -14
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 25
- 14
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -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 {


Loading…
Cancel
Save