Reset folder state on cancelling sync ops

pull/175/head
M66B 6 years ago
parent f7a585e181
commit 4eadb534e7

@ -100,6 +100,9 @@ public interface DaoOperation {
@Query("SELECT * FROM operation WHERE name = :name")
List<EntityOperation> getOperations(String name);
@Query("SELECT * FROM operation WHERE account = :account AND name = :name")
List<EntityOperation> getOperations(long account, String name);
@Query("SELECT * FROM operation WHERE id = :id")
EntityOperation getOperation(long id);
@ -139,7 +142,4 @@ public interface DaoOperation {
@Query("DELETE FROM operation WHERE id = :id")
int deleteOperation(long id);
@Query("DELETE FROM operation WHERE account = :account AND name = :name")
int deleteOperations(long account, String name);
}

@ -1522,8 +1522,14 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
boolean enabled = prefs.getBoolean("enabled", true);
int pollInterval = prefs.getInt("poll_interval", DEFAULT_POLL_INTERVAL);
if (!enabled || account.ondemand || (pollInterval > 0 && !account.poll_exempted)) {
int syncs = db.operation().deleteOperations(account.id, EntityOperation.SYNC);
Log.i(account.name + " cancelled syncs=" + syncs);
List<EntityOperation> syncs = db.operation().getOperations(account.id, EntityOperation.SYNC);
if (syncs != null) {
for (EntityOperation op : syncs) {
db.folder().setFolderSyncState(op.folder, null);
db.operation().deleteOperation(op.id);
}
Log.i(account.name + " cancelled syncs=" + syncs.size());
}
}
// Long back-off period, let device sleep

Loading…
Cancel
Save