mirror of https://github.com/M66B/FairEmail.git
Cancel transient sync operations
This commit is contained in:
parent
9731e17af8
commit
9088dc1f5b
|
@ -139,4 +139,7 @@ public interface DaoOperation {
|
||||||
|
|
||||||
@Query("DELETE FROM operation WHERE id = :id")
|
@Query("DELETE FROM operation WHERE id = :id")
|
||||||
int deleteOperation(long id);
|
int deleteOperation(long id);
|
||||||
|
|
||||||
|
@Query("DELETE FROM operation WHERE account = :account AND name = :name")
|
||||||
|
int deleteOperations(long account, String name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1529,19 +1529,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
Log.w(account.name + " backoff " + ex.toString());
|
Log.w(account.name + " backoff " + ex.toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Stop retrying when on manual sync
|
// Cancel transient sync operations
|
||||||
if (account.ondemand)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Stop retrying when executing operations only
|
|
||||||
boolean enabled = prefs.getBoolean("enabled", true);
|
boolean enabled = prefs.getBoolean("enabled", true);
|
||||||
if (!enabled)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Stop retrying when polling
|
|
||||||
int pollInterval = prefs.getInt("poll_interval", DEFAULT_POLL_INTERVAL);
|
int pollInterval = prefs.getInt("poll_interval", DEFAULT_POLL_INTERVAL);
|
||||||
if (pollInterval > 0 && !account.poll_exempted)
|
if (!enabled || account.ondemand || (pollInterval > 0 && !account.poll_exempted)) {
|
||||||
break;
|
int syncs = db.operation().deleteOperations(account.id, EntityOperation.SYNC);
|
||||||
|
Log.i(account.name + " cancelled syncs=" + syncs);
|
||||||
|
}
|
||||||
|
|
||||||
// Long back-off period, let device sleep
|
// Long back-off period, let device sleep
|
||||||
Intent intent = new Intent(ServiceSynchronize.this, ServiceSynchronize.class);
|
Intent intent = new Intent(ServiceSynchronize.this, ServiceSynchronize.class);
|
||||||
|
|
Loading…
Reference in New Issue