Do not insert empty chunks that loop to themselves
We were getting some stuck timelines because of the insertion of empty chunks that link to themselves in both directions. Change-Id: Id3672e6704d82cbcdafa2fa5ded716b624db3680
This commit is contained in:
parent
42ac513da4
commit
d9e5dfa90a
@ -70,6 +70,19 @@ internal class TokenChunkEventPersistor @Inject constructor(
|
|||||||
suspend fun insertInDb(receivedChunk: TokenChunkEvent,
|
suspend fun insertInDb(receivedChunk: TokenChunkEvent,
|
||||||
roomId: String,
|
roomId: String,
|
||||||
direction: PaginationDirection): Result {
|
direction: PaginationDirection): Result {
|
||||||
|
if (receivedChunk.events.isEmpty() && receivedChunk.start == receivedChunk.end) {
|
||||||
|
Timber.w("Discard empty chunk with identical start/end token ${receivedChunk.start}")
|
||||||
|
|
||||||
|
if (receivedChunk.hasMore()) {
|
||||||
|
Result.SHOULD_FETCH_MORE
|
||||||
|
} else {
|
||||||
|
Result.REACHED_END
|
||||||
|
}
|
||||||
|
} else if (receivedChunk.start == receivedChunk.end) {
|
||||||
|
// I don't think we have seen this case so far, but let's log it just in case...
|
||||||
|
// -> if it happens, we need to address it somehow!
|
||||||
|
Timber.e("Non-empty chunk with identical start/end token ${receivedChunk.start}")
|
||||||
|
}
|
||||||
monarchy
|
monarchy
|
||||||
.awaitTransaction { realm ->
|
.awaitTransaction { realm ->
|
||||||
Timber.i("Start persisting ${receivedChunk.events.size} events in $roomId towards $direction | " +
|
Timber.i("Start persisting ${receivedChunk.events.size} events in $roomId towards $direction | " +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user