Improved operation handling/display

This commit is contained in:
M66B
2019-01-29 11:06:53 +00:00
parent da9c2062d4
commit 25ff074a86
5 changed files with 109 additions and 89 deletions

View File

@@ -1189,7 +1189,7 @@ public class ServiceSynchronize extends LifecycleService {
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":folder." + folder.id);
@Override
public void onChanged(List<EntityOperation> operations) {
public void onChanged(final List<EntityOperation> operations) {
boolean process = false;
List<Long> current = new ArrayList<>();
for (EntityOperation op : operations) {
@@ -1229,7 +1229,7 @@ public class ServiceSynchronize extends LifecycleService {
db.folder().setFolderError(folder.id, null);
}
processOperations(account, folder, isession, istore, ifolder, state);
processOperations(account, folder, operations, isession, istore, ifolder, state);
} catch (Throwable ex) {
Log.e(folder.name, ex);
@@ -1432,13 +1432,14 @@ public class ServiceSynchronize extends LifecycleService {
}
}
private void processOperations(EntityAccount account, EntityFolder folder, Session isession, IMAPStore istore, IMAPFolder ifolder, ServiceState state) throws MessagingException, JSONException, IOException {
private void processOperations(
EntityAccount account, EntityFolder folder, List<EntityOperation> ops, Session isession,
IMAPStore istore, IMAPFolder ifolder, ServiceState state)
throws MessagingException, JSONException, IOException {
try {
Log.i(folder.name + " start process");
DB db = DB.getInstance(this);
List<EntityOperation> ops = db.operation().getOperationsByFolder(
folder.id, EntityFolder.OUTBOX.equals(folder.type));
Log.i(folder.name + " pending operations=" + ops.size());
for (int i = 0; i < ops.size() && state.running(); i++) {
EntityOperation op = ops.get(i);
@@ -1866,11 +1867,8 @@ public class ServiceSynchronize extends LifecycleService {
private void doSend(EntityMessage message, DB db) throws MessagingException, IOException {
// Send message
EntityIdentity ident = db.identity().getIdentity(message.identity);
if (!ident.synchronize) {
// Message will remain in outbox
return;
}
// Mark attempt
if (message.last_attempt == null) {
message.last_attempt = new Date().getTime();
db.message().setMessageLastAttempt(message.id, message.last_attempt);
@@ -3005,7 +3003,7 @@ public class ServiceSynchronize extends LifecycleService {
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":outbox");
@Override
public void onChanged(List<EntityOperation> operations) {
public void onChanged(final List<EntityOperation> operations) {
boolean process = false;
List<Long> current = new ArrayList<>();
for (EntityOperation op : operations) {
@@ -3025,7 +3023,7 @@ public class ServiceSynchronize extends LifecycleService {
Log.i(outbox.name + " process");
db.folder().setFolderSyncState(outbox.id, "syncing");
processOperations(null, outbox, null, null, null, state);
processOperations(null, outbox, operations, null, null, null, state);
db.folder().setFolderError(outbox.id, null);
} catch (Throwable ex) {
Log.e(outbox.name, ex);