Skip to content
Snippets Groups Projects
Commit 65a1d165 authored by Greyson Parrelli's avatar Greyson Parrelli
Browse files

Fix issue where storage dirty state wasn't cleared.

parent e3b27bd3
Branches
Tags
No related merge requests found
......@@ -206,7 +206,7 @@ public class StorageSyncJobV2 extends BaseJob {
private boolean performSync() throws IOException, RetryLaterException, InvalidKeyException {
Stopwatch stopwatch = new Stopwatch("StorageSync");
Recipient self = Recipient.self();
Recipient self = Recipient.self().fresh();
SQLiteDatabase db = DatabaseFactory.getInstance(context).getRawDatabase();
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientDatabase(context);
......@@ -236,6 +236,8 @@ public class StorageSyncJobV2 extends BaseJob {
Log.i(TAG, "[Remote Sync] Pre-Merge ID Difference :: " + idDifference);
stopwatch.split("remote-id-diff");
if (!idDifference.isEmpty()) {
Log.i(TAG, "[Remote Sync] Retrieving records for key difference.");
......@@ -277,6 +279,8 @@ public class StorageSyncJobV2 extends BaseJob {
new GroupV2RecordProcessor(context).process(remoteGv2, StorageSyncHelper.KEY_GENERATOR);
new AccountRecordProcessor(context, self).process(remoteAccount, StorageSyncHelper.KEY_GENERATOR);
self = Recipient.self().fresh();
List<SignalStorageRecord> unknownInserts = remoteUnknown;
List<StorageId> unknownDeletes = Stream.of(idDifference.getLocalOnlyIds()).filter(StorageId::isUnknown).toList();
......@@ -301,13 +305,15 @@ public class StorageSyncJobV2 extends BaseJob {
remoteInserts,
remoteDeletes);
recipientDatabase.clearDirtyStateForStorageIds(Util.concatenatedList(localIdsAdded, localIdsRemoved));
db.setTransactionSuccessful();
} finally {
db.endTransaction();
ApplicationDependencies.getDatabaseObserver().notifyConversationListListeners();
}
stopwatch.split("local-merge");
stopwatch.split("remote-merge-transaction");
Log.i(TAG, "[Remote Sync] WriteOperationResult :: " + mergeWriteOperation);
......@@ -375,7 +381,7 @@ public class StorageSyncJobV2 extends BaseJob {
db.endTransaction();
}
stopwatch.split("local-changes");
stopwatch.split("local-changes-transaction");
if (localWriteResult.isPresent()) {
Log.i(TAG, String.format(Locale.ENGLISH, "[Local Changes] Local changes present. %d updates, %d inserts, %d deletes, account update: %b, account insert: %b.", pendingUpdates.size(), pendingInsertions.size(), pendingDeletions.size(), pendingAccountUpdate.isPresent(), pendingAccountInsert.isPresent()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment