1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-02 13:14:39 +00:00

Consider system folders as subscribed to

This commit is contained in:
M66B 2019-06-25 16:34:30 +02:00
parent 3288ae1d45
commit dfcbd40dbe

View file

@ -797,7 +797,7 @@ class Core {
boolean sync_folders = prefs.getBoolean("sync_folders", true); boolean sync_folders = prefs.getBoolean("sync_folders", true);
// Get folder names // Get folder names
List<String> names = new ArrayList<>(); Map<String, EntityFolder> local = new HashMap<>();
for (EntityFolder folder : db.folder().getFolders(account.id)) for (EntityFolder folder : db.folder().getFolders(account.id))
if (folder.tbc != null) { if (folder.tbc != null) {
Log.i(folder.name + " creating"); Log.i(folder.name + " creating");
@ -805,7 +805,7 @@ class Core {
if (!ifolder.exists()) if (!ifolder.exists())
ifolder.create(Folder.HOLDS_MESSAGES); ifolder.create(Folder.HOLDS_MESSAGES);
db.folder().resetFolderTbc(folder.id); db.folder().resetFolderTbc(folder.id);
names.add(folder.name); local.put(folder.name, folder);
sync_folders = true; sync_folders = true;
} else if (folder.tbd != null && folder.tbd) { } else if (folder.tbd != null && folder.tbd) {
Log.i(folder.name + " deleting"); Log.i(folder.name + " deleting");
@ -815,11 +815,11 @@ class Core {
db.folder().deleteFolder(folder.id); db.folder().deleteFolder(folder.id);
sync_folders = true; sync_folders = true;
} else { } else {
names.add(folder.name); local.put(folder.name, folder);
if (folder.initialize != 0) if (folder.initialize != 0)
sync_folders = true; sync_folders = true;
} }
Log.i("Local folder count=" + names.size()); Log.i("Local folder count=" + local.size());
if (!sync_folders) if (!sync_folders)
return; return;
@ -875,7 +875,7 @@ class Core {
" type=" + type + " attrs=" + TextUtils.join(" ", attr)); " type=" + type + " attrs=" + TextUtils.join(" ", attr));
if (type != null) { if (type != null) {
names.remove(fullName); local.remove(fullName);
EntityFolder folder; EntityFolder folder;
try { try {
@ -935,10 +935,14 @@ class Core {
db.folder().setFolderParent(child.id, parent == null ? null : parent.id); db.folder().setFolderParent(child.id, parent == null ? null : parent.id);
} }
Log.i("Delete local count=" + names.size()); Log.i("Delete local count=" + local.size());
for (String name : names) { for (String name : local.keySet()) {
Log.i(name + " delete"); EntityFolder folder = local.get(name);
db.folder().deleteFolder(account.id, name); if (EntityFolder.USER.equals(folder.type)) {
Log.i(name + " delete");
db.folder().deleteFolder(account.id, name);
} else
Log.i(name + " keep type=" + folder.type);
} }
} }