Revert "Optimized synchronizing folders"

This reverts commit 096c0d98b9.
pull/178/head
M66B 5 years ago
parent 096c0d98b9
commit 7608307a70

@ -1280,19 +1280,9 @@ class Core {
long start = new Date().getTime(); long start = new Date().getTime();
Folder[] ifolders = defaultFolder.list("*"); Folder[] ifolders = defaultFolder.list("*");
List<String> subscription = new ArrayList<>();
try {
Folder[] isubscribed = defaultFolder.listSubscribed("*");
for (Folder ifolder : isubscribed)
subscription.add(ifolder.getFullName());
} catch (MessagingException ex) {
Log.e(account.name, ex);
}
long duration = new Date().getTime() - start; long duration = new Date().getTime() - start;
Log.i("Remote folder count=" + ifolders.length + Log.i("Remote folder count=" + ifolders.length +
" subscribed=" + subscription.size() +
" separator=" + separator + " separator=" + separator +
" fetched in " + duration + " ms"); " fetched in " + duration + " ms");
@ -1302,7 +1292,7 @@ class Core {
String fullName = ifolder.getFullName(); String fullName = ifolder.getFullName();
String[] attrs = ((IMAPFolder) ifolder).getAttributes(); String[] attrs = ((IMAPFolder) ifolder).getAttributes();
String type = EntityFolder.getType(attrs, fullName, false); String type = EntityFolder.getType(attrs, fullName, false);
boolean subscribed = subscription.contains(fullName); boolean subscribed = ifolder.isSubscribed();
boolean selectable = true; boolean selectable = true;
boolean inferiors = true; boolean inferiors = true;
@ -1322,13 +1312,14 @@ class Core {
" attrs=" + TextUtils.join(" ", attrs)); " attrs=" + TextUtils.join(" ", attrs));
if (type != null) { if (type != null) {
EntityFolder folder = local.get(fullName);
local.remove(fullName); local.remove(fullName);
if (folder == null) { EntityFolder folder;
try { try {
db.beginTransaction(); db.beginTransaction();
folder = db.folder().getFolderByName(account.id, fullName);
if (folder == null) {
folder = new EntityFolder(); folder = new EntityFolder();
folder.account = account.id; folder.account = account.id;
folder.name = fullName; folder.name = fullName;
@ -1342,15 +1333,7 @@ class Core {
folder.inferiors = inferiors; folder.inferiors = inferiors;
folder.id = db.folder().insertFolder(folder); folder.id = db.folder().insertFolder(folder);
Log.i(folder.name + " added type=" + folder.type); Log.i(folder.name + " added type=" + folder.type);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
} else { } else {
try {
db.beginTransaction();
Log.i(folder.name + " exists type=" + folder.type); Log.i(folder.name + " exists type=" + folder.type);
if (folder.subscribed == null || !folder.subscribed.equals(subscribed)) if (folder.subscribed == null || !folder.subscribed.equals(subscribed))
@ -1371,11 +1354,11 @@ class Core {
if (db.folder().getFolderByType(folder.account, EntityFolder.INBOX) == null) if (db.folder().getFolderByType(folder.account, EntityFolder.INBOX) == null)
db.folder().setFolderType(folder.id, type); db.folder().setFolderType(folder.id, type);
} }
}
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
db.endTransaction(); db.endTransaction();
} Log.i("End sync folder");
} }
nameFolder.put(folder.name, folder); nameFolder.put(folder.name, folder);

Loading…
Cancel
Save