mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-26 07:53:12 +00:00
Replace fetches by sync
This commit is contained in:
parent
8fe589ed45
commit
e371eb9948
1 changed files with 23 additions and 0 deletions
|
@ -150,6 +150,7 @@ class Core {
|
||||||
private static final long LOCAL_RETRY_DELAY = 5 * 1000L; // milliseconds
|
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 TOTAL_RETRY_MAX = LOCAL_RETRY_MAX * 5;
|
||||||
private static final int MAX_PREVIEW = 5000; // characters
|
private static final int MAX_PREVIEW = 5000; // characters
|
||||||
|
private static final int MAX_FETCH = 100;
|
||||||
|
|
||||||
static void processOperations(
|
static void processOperations(
|
||||||
Context context,
|
Context context,
|
||||||
|
@ -162,6 +163,28 @@ class Core {
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
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;
|
int retry = 0;
|
||||||
boolean group = true;
|
boolean group = true;
|
||||||
Log.i(folder.name + " executing operations=" + ops.size());
|
Log.i(folder.name + " executing operations=" + ops.size());
|
||||||
|
|
Loading…
Reference in a new issue