Skip to content

Commit

Permalink
Fix ChunkEntity.isMoreRecentThan() if both chunks linked to last forward
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SpiritCroc committed Mar 11, 2022
1 parent 0564942 commit 366e44f
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ internal fun ChunkEntity.isMoreRecentThan(chunkToCheck: ChunkEntity): Boolean {
if (chunkToCheck.doesNextChunksVerifyCondition { it == this }) {
return true
}
if (this.doesNextChunksVerifyCondition { it == chunkToCheck }) {
return false
}
// Otherwise check if this chunk is linked to last forward
if (this.doesNextChunksVerifyCondition { it.isLastForward }) {
return true
Expand Down

0 comments on commit 366e44f

Please sign in to comment.