|
@ -482,7 +482,12 @@ public class ServiceSynchronize extends LifecycleService { |
|
|
db.folder().setFolderState(folder.id, "connecting"); |
|
|
db.folder().setFolderState(folder.id, "connecting"); |
|
|
|
|
|
|
|
|
final IMAPFolder ifolder = (IMAPFolder) istore.getFolder(folder.name); |
|
|
final IMAPFolder ifolder = (IMAPFolder) istore.getFolder(folder.name); |
|
|
ifolder.open(Folder.READ_WRITE); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
ifolder.open(Folder.READ_WRITE); |
|
|
|
|
|
} catch (Throwable ex) { |
|
|
|
|
|
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); |
|
|
|
|
|
throw ex; |
|
|
|
|
|
} |
|
|
folders.put(folder, ifolder); |
|
|
folders.put(folder, ifolder); |
|
|
|
|
|
|
|
|
db.folder().setFolderState(folder.id, "connected"); |
|
|
db.folder().setFolderState(folder.id, "connected"); |
|
@ -684,8 +689,13 @@ public class ServiceSynchronize extends LifecycleService { |
|
|
if (db.operation().getOperationCount(fid) == 0) |
|
|
if (db.operation().getOperationCount(fid) == 0) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
db.folder().setFolderState(folder.id, "connecting"); |
|
|
|
|
|
|
|
|
ifolder = (IMAPFolder) istore.getFolder(folder.name); |
|
|
ifolder = (IMAPFolder) istore.getFolder(folder.name); |
|
|
ifolder.open(Folder.READ_WRITE); |
|
|
ifolder.open(Folder.READ_WRITE); |
|
|
|
|
|
|
|
|
|
|
|
db.folder().setFolderState(folder.id, "connected"); |
|
|
|
|
|
db.folder().setFolderError(folder.id, null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (ACTION_PROCESS_OPERATIONS.equals(intent.getAction())) |
|
|
if (ACTION_PROCESS_OPERATIONS.equals(intent.getAction())) |
|
@ -697,15 +707,20 @@ public class ServiceSynchronize extends LifecycleService { |
|
|
} catch (Throwable ex) { |
|
|
} catch (Throwable ex) { |
|
|
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); |
|
|
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); |
|
|
reportError(account.name, folder.name, ex); |
|
|
reportError(account.name, folder.name, ex); |
|
|
|
|
|
|
|
|
|
|
|
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex)); |
|
|
} finally { |
|
|
} finally { |
|
|
if (shouldClose) |
|
|
|
|
|
|
|
|
if (shouldClose) { |
|
|
if (ifolder != null && ifolder.isOpen()) { |
|
|
if (ifolder != null && ifolder.isOpen()) { |
|
|
|
|
|
db.folder().setFolderState(folder.id, "closing"); |
|
|
try { |
|
|
try { |
|
|
ifolder.close(false); |
|
|
ifolder.close(false); |
|
|
} catch (MessagingException ex) { |
|
|
} catch (MessagingException ex) { |
|
|
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); |
|
|
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
db.folder().setFolderState(folder.id, null); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|