Do not reuse room files if the room is marked for deletion #1390
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes 5717, possibly related to element-hq/element-ios#5107, but could not reproduce the latter
When a user joins an invited room, the SDK will mark all previous room data for deletion, which includes a bunch of temporary events with fake IDs. It is sensible to delete this data, because it will be redownloaded from the server again.
... However.
The
MXFileStore
does not immediately delete the actual files, and another piece of code is already busy preparing room for the next events. Because the data hasn't yet been wiped away, the new room state is able to load it up into memory, and when the files are actually deleted, theMXFileStore
already has anotherRoomState
with those messages cached. At the nextcommit
phase, it will save them back to the disk, incl the events that should have been deleted. A user facing result of this is some duplicate events, such as start of the room header.To solve this the
MXFileStore
is not allowed to get an existing messages file if the roomID is marked for deletion in the nextcommit
phase.