diff --git a/bramble-core/src/main/java/org/briarproject/bramble/versioning/ClientVersioningManagerImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/versioning/ClientVersioningManagerImpl.java index 7f3a96f1fee2c8aac289790ea1376522bdd446e6..1af256a3c74ac044c651645429894c4e9c200504 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/versioning/ClientVersioningManagerImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/versioning/ClientVersioningManagerImpl.java @@ -305,14 +305,17 @@ class ClientVersioningManagerImpl implements ClientVersioningManager, Client, Update oldLocalUpdate = loadUpdate(txn, latest.local.messageId); List<ClientState> oldLocalStates = oldLocalUpdate.states; long oldLocalUpdateVersion = oldLocalUpdate.updateVersion; - // Delete the latest local update - db.deleteMessage(txn, latest.local.messageId); - db.deleteMessageMetadata(txn, latest.local.messageId); - // Store a new local update + // Update the local states if necessary List<ClientState> newLocalStates = updateStatesFromLocalVersions(oldLocalStates, versions); - storeUpdate(txn, g.getId(), newLocalStates, - oldLocalUpdateVersion + 1); + if (!oldLocalStates.equals(newLocalStates)) { + // Delete the latest local update + db.deleteMessage(txn, latest.local.messageId); + db.deleteMessageMetadata(txn, latest.local.messageId); + // Store a new local update + storeUpdate(txn, g.getId(), newLocalStates, + oldLocalUpdateVersion + 1); + } // Load and parse the latest remote update, if any List<ClientState> remoteStates; if (latest.remote == null) remoteStates = emptyList();