Browse Source

Folder state fixes

main
M66B 6 years ago
parent
commit
ce29fa7c6b
3 changed files with 18 additions and 3 deletions
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. +1
    -1
      app/src/main/java/eu/faircode/email/AdapterFolder.java
  3. +17
    -2
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

BIN
.idea/caches/build_file_checksums.ser View File


+ 1
- 1
app/src/main/java/eu/faircode/email/AdapterFolder.java View File

@ -119,7 +119,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ivState.setImageResource(R.drawable.baseline_compare_arrows_24);
else
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.setVisibility(folder.error == null ? View.GONE : View.VISIBLE);


+ 17
- 2
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

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


Loading…
Cancel
Save