mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-28 11:55:20 +01:00
Guarantee poll
This commit is contained in:
@@ -19,6 +19,8 @@ package eu.faircode.email;
|
||||
Copyright 2018-2021 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import static androidx.room.ForeignKey.CASCADE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.text.TextUtils;
|
||||
@@ -44,8 +46,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static androidx.room.ForeignKey.CASCADE;
|
||||
|
||||
@Entity(
|
||||
tableName = EntityOperation.TABLE_NAME,
|
||||
foreignKeys = {
|
||||
@@ -425,6 +425,22 @@ public class EntityOperation {
|
||||
Log.breadcrumb("queued", crumb);
|
||||
}
|
||||
|
||||
static void poll(Context context, long fid) throws JSONException {
|
||||
DB db = DB.getInstance(context);
|
||||
|
||||
boolean force = false;
|
||||
List<EntityOperation> ops = db.operation().getOperationsByFolder(fid, EntityOperation.SYNC);
|
||||
if (ops != null)
|
||||
for (EntityOperation op : ops)
|
||||
if (EntityFolder.isSyncForced(op.args)) {
|
||||
force = true;
|
||||
break;
|
||||
}
|
||||
|
||||
db.operation().deleteOperation(fid, EntityOperation.SYNC);
|
||||
sync(context, fid, false, force);
|
||||
}
|
||||
|
||||
static void sync(Context context, long fid, boolean foreground) {
|
||||
sync(context, fid, foreground, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user