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();
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;
Log.i("Remote folder count=" + ifolders.length +
" subscribed=" + subscription.size() +
" separator=" + separator +
" fetched in " + duration + " ms");
@ -1302,7 +1292,7 @@ class Core {
String fullName = ifolder.getFullName();
String[] attrs = ((IMAPFolder) ifolder).getAttributes();
String type = EntityFolder.getType(attrs, fullName, false);
boolean subscribed = subscription.contains(fullName);
boolean subscribed = ifolder.isSubscribed();
boolean selectable = true;
boolean inferiors = true;
@ -1322,13 +1312,14 @@ class Core {
" attrs=" + TextUtils.join(" ", attrs));
if (type != null) {
EntityFolder folder = local.get(fullName);
local.remove(fullName);
if (folder == null) {
EntityFolder folder;
try {
db.beginTransaction();
folder = db.folder().getFolderByName(account.id, fullName);
if (folder == null) {
folder = new EntityFolder();
folder.account = account.id;
folder.name = fullName;
@ -1342,15 +1333,7 @@ class Core {
folder.inferiors = inferiors;
folder.id = db.folder().insertFolder(folder);
Log.i(folder.name + " added type=" + folder.type);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
} else {
try {
db.beginTransaction();
Log.i(folder.name + " exists type=" + folder.type);
if (folder.subscribed == null || !folder.subscribed.equals(subscribed))
@ -1371,11 +1354,11 @@ class Core {
if (db.folder().getFolderByType(folder.account, EntityFolder.INBOX) == null)
db.folder().setFolderType(folder.id, type);
}
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
Log.i("End sync folder");
}
nameFolder.put(folder.name, folder);

Loading…
Cancel
Save