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

Replace fetches by sync

This commit is contained in:
M66B 2020-11-05 18:15:04 +01:00
parent 8fe589ed45
commit e371eb9948

View file

@ -150,6 +150,7 @@ class Core {
private static final long LOCAL_RETRY_DELAY = 5 * 1000L; // milliseconds
private static final int TOTAL_RETRY_MAX = LOCAL_RETRY_MAX * 5;
private static final int MAX_PREVIEW = 5000; // characters
private static final int MAX_FETCH = 100;
static void processOperations(
Context context,
@ -162,6 +163,28 @@ class Core {
DB db = DB.getInstance(context);
// Replace fetches by sync
List<EntityOperation> fetches = new ArrayList<>();
for (EntityOperation op : ops)
if (EntityOperation.FETCH.equals(op.name))
fetches.add(op);
if (fetches.size() > MAX_FETCH) {
EntityLog.log(context, "Replacing fetches=" + fetches.size() + " by sync");
try {
db.beginTransaction();
for (EntityOperation op : fetches) {
db.operation().deleteOperation(op.id);
ops.remove(op);
}
EntityOperation.sync(context, folder.id, false);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
int retry = 0;
boolean group = true;
Log.i(folder.name + " executing operations=" + ops.size());