Folder state fixes

pull/91/head
M66B 6 years ago
parent 28b01666c6
commit ce29fa7c6b

@ -119,7 +119,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ivState.setImageResource(R.drawable.baseline_compare_arrows_24); ivState.setImageResource(R.drawable.baseline_compare_arrows_24);
else else
ivState.setImageResource(R.drawable.baseline_cloud_off_24); ivState.setImageResource(R.drawable.baseline_cloud_off_24);
ivState.setVisibility(folder.synchronize || outbox ? View.VISIBLE : View.INVISIBLE); ivState.setVisibility(folder.synchronize || "syncing".equals(folder.state) || outbox ? View.VISIBLE : View.INVISIBLE);
tvError.setText(folder.error); tvError.setText(folder.error);
tvError.setVisibility(folder.error == null ? View.GONE : View.VISIBLE); tvError.setVisibility(folder.error == null ? View.GONE : View.VISIBLE);

@ -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);
}
} }
} }
}); });

Loading…
Cancel
Save