Reset failed foreground sync

pull/152/head
M66B 6 years ago
parent e71f6d5db1
commit f80d6c683b

@ -222,7 +222,7 @@ class Core {
if (ex instanceof MessageRemovedException || if (ex instanceof MessageRemovedException ||
ex instanceof FolderNotFoundException || ex instanceof FolderNotFoundException ||
ex instanceof IllegalArgumentException) { ex instanceof IllegalArgumentException) {
Log.w("Unrecoverable", ex); Log.w("Unrecoverable");
// There is no use in repeating // There is no use in repeating
db.operation().deleteOperation(op.id); db.operation().deleteOperation(op.id);
@ -254,12 +254,18 @@ class Core {
} else if (ex instanceof MessagingException) { } else if (ex instanceof MessagingException) {
// Socket timeout is a recoverable condition (send message) // Socket timeout is a recoverable condition (send message)
if (ex.getCause() instanceof SocketTimeoutException) { if (ex.getCause() instanceof SocketTimeoutException) {
Log.w("Recoverable", ex); Log.w("Recoverable");
// No need to inform user // No need to inform user
return; return;
} }
} }
if (EntityOperation.SYNC.equals(op.name) && jargs.getBoolean(3) /* foreground */) {
Log.w("Deleting foreground SYNC");
db.operation().deleteOperation(op.id);
db.folder().setFolderSyncState(folder.id, null);
}
throw ex; throw ex;
} }
} finally { } finally {

@ -228,11 +228,14 @@ public class EntityOperation {
if (folder.account != null) if (folder.account != null)
account = db.account().getAccount(folder.account); account = db.account().getAccount(folder.account);
JSONArray jargs = folder.getSyncArgs();
jargs.put(foreground);
EntityOperation operation = new EntityOperation(); EntityOperation operation = new EntityOperation();
operation.folder = folder.id; operation.folder = folder.id;
operation.message = null; operation.message = null;
operation.name = SYNC; operation.name = SYNC;
operation.args = folder.getSyncArgs().toString(); operation.args = jargs.toString();
operation.created = new Date().getTime(); operation.created = new Date().getTime();
operation.id = db.operation().insertOperation(operation); operation.id = db.operation().insertOperation(operation);

Loading…
Cancel
Save