1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-23 22:51:02 +00:00

Added logging, refactor reforce sync

This commit is contained in:
M66B 2021-07-30 16:23:07 +02:00
parent 2b8b47c32e
commit 80da26cc22
2 changed files with 17 additions and 8 deletions

View file

@ -324,6 +324,11 @@ public class EntityFolder extends EntityOrder implements Serializable {
return jargs;
}
static boolean isSyncForced(String args) throws JSONException {
JSONArray jargs = new JSONArray(args);
return jargs.optBoolean(5, false);
}
static int getIcon(String type) {
if (EntityFolder.INBOX.equals(type))
return R.drawable.twotone_inbox_24;

View file

@ -1907,19 +1907,23 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} else {
if (folder.poll_count == 0) {
// Cancel pending sync, for example when the folder is not set to poll
boolean fforce = false;
List<EntityOperation> ops = db.operation().getOperations(folder.account, EntityOperation.SYNC);
if (ops.size() == 0)
EntityOperation.sync(this, folder.id, false);
else
for (EntityOperation op : ops) {
db.operation().deleteOperation(op.id);
op.id = null;
op.id = db.operation().insertOperation(op);
for (EntityOperation op : ops)
if (EntityFolder.isSyncForced(op.args)) {
fforce = true;
break;
}
db.operation().deleteOperation(folder.id, EntityOperation.SYNC);
EntityLog.log(this, folder.name + " queue sync poll");
EntityOperation.sync(this, folder.id, false, fforce);
}
folder.poll_count = (folder.poll_count + 1) % folder.poll_factor;
db.folder().setFolderPollCount(folder.id, folder.poll_count);
Log.i(folder.name + " poll count=" + folder.poll_count);
EntityLog.log(this, folder.name +
" poll count=" + folder.poll_count +
" factor=" + folder.poll_factor);
}
}
} catch (Throwable ex) {