Skip to content

Commit 366e44f

Browse files
committed
Fix ChunkEntity.isMoreRecentThan() if both chunks linked to last forward
Imagine scenario: [chunkToCheck] -> [this] -> [lastForwardChunk] Then, both `isLastForward` checks will not return, and also the `chunkToCheck.doesNextChunksVerifyCondition { it == this }` will return false. Since both chunks are connected to the last forward chunk, `isMoreRecent()` will still return `true`, which is wrong in this case. So do not only check if chunkToCheck has this as any of the next chunks, but also the other way round.
1 parent 0564942 commit 366e44f

File tree

1 file changed

+3
-0
lines changed
  • matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper

1 file changed

+3
-0
lines changed

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ChunkEntityHelper.kt

+3
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ internal fun ChunkEntity.isMoreRecentThan(chunkToCheck: ChunkEntity): Boolean {
223223
if (chunkToCheck.doesNextChunksVerifyCondition { it == this }) {
224224
return true
225225
}
226+
if (this.doesNextChunksVerifyCondition { it == chunkToCheck }) {
227+
return false
228+
}
226229
// Otherwise check if this chunk is linked to last forward
227230
if (this.doesNextChunksVerifyCondition { it.isLastForward }) {
228231
return true

0 commit comments

Comments
 (0)