mirror of https://github.com/M66B/FairEmail.git
Fixed race condition
This commit is contained in:
parent
51e256ab9c
commit
82d2c7e03a
|
@ -1142,10 +1142,11 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void synchronizeFolders(EntityAccount account, IMAPStore istore, ServiceState state) throws MessagingException {
|
private void synchronizeFolders(EntityAccount account, IMAPStore istore, ServiceState state) throws MessagingException {
|
||||||
try {
|
|
||||||
Log.v(Helper.TAG, "Start sync folders");
|
|
||||||
|
|
||||||
DB db = DB.getInstance(this);
|
DB db = DB.getInstance(this);
|
||||||
|
try {
|
||||||
|
db.beginTransaction();
|
||||||
|
|
||||||
|
Log.v(Helper.TAG, "Start sync folders");
|
||||||
|
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
for (EntityFolder folder : db.folder().getUserFolders(account.id))
|
for (EntityFolder folder : db.folder().getUserFolders(account.id))
|
||||||
|
@ -1156,9 +1157,6 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
Log.i(Helper.TAG, "Remote folder count=" + ifolders.length);
|
Log.i(Helper.TAG, "Remote folder count=" + ifolders.length);
|
||||||
|
|
||||||
for (Folder ifolder : ifolders) {
|
for (Folder ifolder : ifolders) {
|
||||||
if (!state.running)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String[] attrs = ((IMAPFolder) ifolder).getAttributes();
|
String[] attrs = ((IMAPFolder) ifolder).getAttributes();
|
||||||
boolean selectable = true;
|
boolean selectable = true;
|
||||||
for (String attr : attrs) {
|
for (String attr : attrs) {
|
||||||
|
@ -1193,7 +1191,10 @@ public class ServiceSynchronize extends LifecycleService {
|
||||||
Log.i(Helper.TAG, "Delete local folder=" + names.size());
|
Log.i(Helper.TAG, "Delete local folder=" + names.size());
|
||||||
for (String name : names)
|
for (String name : names)
|
||||||
db.folder().deleteFolder(account.id, name);
|
db.folder().deleteFolder(account.id, name);
|
||||||
|
|
||||||
|
db.setTransactionSuccessful();
|
||||||
} finally {
|
} finally {
|
||||||
|
db.endTransaction();
|
||||||
Log.v(Helper.TAG, "End sync folder");
|
Log.v(Helper.TAG, "End sync folder");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue