diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-10-29 12:34:57 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-10-29 12:34:57 +0300 |
commit | a0693708b224ce4fe9cf11150edbd487d4df549b (patch) | |
tree | e5920dc2e8420c857718ef99d9b5dfa28276bdba /app/src/main/java/it/niedermann/nextcloud/deck/persistence | |
parent | 5c858d70a08f13ae5c3dfb48d1166cf4c0ab76ce (diff) |
#715 Use java.time.*
Reset wrong last sync timestamps
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/persistence')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java | 4 | ||||
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DeckDatabase.java | 16 |
2 files changed, 16 insertions, 4 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java index f40a1821b..ee36ad1b5 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/SyncManager.java @@ -79,7 +79,6 @@ import it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.LabelData import it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.StackDataProvider; import it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.partial.BoardWithAclDownSyncDataProvider; import it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.partial.BoardWithStacksAndLabelsUpSyncDataProvider; -import it.niedermann.nextcloud.deck.util.DateUtil; import static java.net.HttpURLConnection.HTTP_NOT_MODIFIED; import static java.net.HttpURLConnection.HTTP_UNAVAILABLE; @@ -212,7 +211,6 @@ public class SyncManager { if (response.getDeckVersion().isSupported(appContext)) { long accountId = callbackAccountId; Instant lastSyncDate = LastSyncUtil.getLastSyncDate(callbackAccountId); - Instant now = DateUtil.nowInGMT(); final SyncHelper syncHelper = new SyncHelper(serverAdapter, dataBaseAdapter, lastSyncDate); @@ -223,7 +221,7 @@ public class SyncManager { @Override public void onResponse(Boolean response) { // TODO deactivate for dev - LastSyncUtil.setLastSyncDate(accountId, now); + LastSyncUtil.setLastSyncDate(accountId, Instant.now()); respondCallbacksAfterSync(callbacksQueueForSync, response, null); } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DeckDatabase.java b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DeckDatabase.java index d2106f03b..0ac0f786b 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DeckDatabase.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/persistence/sync/adapters/db/DeckDatabase.java @@ -1,6 +1,7 @@ package it.niedermann.nextcloud.deck.persistence.sync.adapters.db; import android.content.Context; +import android.content.SharedPreferences; import android.database.Cursor; import android.graphics.Color; @@ -96,7 +97,7 @@ import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.widgets.Sta UserInBoard.class, }, exportSchema = false, - version = 21 + version = 22 ) @TypeConverters({DateTypeConverter.class}) public abstract class DeckDatabase extends RoomDatabase { @@ -420,6 +421,19 @@ public abstract class DeckDatabase extends RoomDatabase { .addMigrations(MIGRATION_18_19) .addMigrations(MIGRATION_19_20) .addMigrations(MIGRATION_20_21) + .addMigrations(new Migration(21, 22) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + // https://github.com/stefan-niedermann/nextcloud-deck/issues/715 + final SharedPreferences.Editor lastSyncPref = context.getApplicationContext().getSharedPreferences("it.niedermann.nextcloud.deck.last_sync", Context.MODE_PRIVATE).edit(); + Cursor cursor = database.query("select id from `Account`"); + while (cursor.moveToNext()) { + lastSyncPref.remove("lS_" + cursor.getLong(0)); + } + cursor.close(); + lastSyncPref.apply(); + } + }) .fallbackToDestructiveMigration() .addCallback(ON_CREATE_CALLBACK) .build(); |