Undo GapWriter algorithm changes
This commit is contained in:
parent
9f6c48cf0c
commit
50c8b995c3
1 changed files with 14 additions and 16 deletions
|
@ -47,30 +47,28 @@ export class GapWriter {
|
||||||
}
|
}
|
||||||
nonOverlappingEvents.push(...remainingEvents.slice(0, duplicateEventIndex));
|
nonOverlappingEvents.push(...remainingEvents.slice(0, duplicateEventIndex));
|
||||||
if (!expectedOverlappingEventId || duplicateEventId === expectedOverlappingEventId) {
|
if (!expectedOverlappingEventId || duplicateEventId === expectedOverlappingEventId) {
|
||||||
// Only link fragment if this is the first overlapping fragment we discover.
|
|
||||||
// TODO is this sufficient? Might we get "out of order" fragments from events?
|
|
||||||
if (!neighbourFragmentEntry) {
|
|
||||||
// TODO: check here that the neighbourEvent is at the correct edge of it's fragment
|
// TODO: check here that the neighbourEvent is at the correct edge of it's fragment
|
||||||
// get neighbour fragment to link it up later on
|
// get neighbour fragment to link it up later on
|
||||||
const neighbourEvent = await txn.timelineEvents.getByEventId(this._roomId, duplicateEventId);
|
const neighbourEvent = await txn.timelineEvents.getByEventId(this._roomId, duplicateEventId);
|
||||||
|
if (neighbourEvent.fragmentId === fragmentEntry.fragmentId) {
|
||||||
|
log.log("hit #160, prevent fragment linking to itself", log.level.Warn);
|
||||||
|
} else {
|
||||||
const neighbourFragment = await txn.timelineFragments.get(this._roomId, neighbourEvent.fragmentId);
|
const neighbourFragment = await txn.timelineFragments.get(this._roomId, neighbourEvent.fragmentId);
|
||||||
neighbourFragmentEntry = fragmentEntry.createNeighbourEntry(neighbourFragment);
|
neighbourFragmentEntry = fragmentEntry.createNeighbourEntry(neighbourFragment);
|
||||||
}
|
}
|
||||||
}
|
// trim overlapping events
|
||||||
// If more events remain, or if this wasn't the expected overlapping event,
|
remainingEvents = null;
|
||||||
|
} else {
|
||||||
// we've hit https://github.com/matrix-org/synapse/issues/7164,
|
// we've hit https://github.com/matrix-org/synapse/issues/7164,
|
||||||
// e.g. the event id we found is already in our store but it is not
|
// e.g. the event id we found is already in our store but it is not
|
||||||
// the adjacent fragment id. Ignore the event, but keep processing the ones after.
|
// the adjacent fragment id. Ignore the event, but keep processing the ones after.
|
||||||
remainingEvents = remainingEvents.slice(duplicateEventIndex + 1);
|
remainingEvents = remainingEvents.slice(duplicateEventIndex + 1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
nonOverlappingEvents.push(...remainingEvents);
|
nonOverlappingEvents.push(...remainingEvents);
|
||||||
remainingEvents = null;
|
remainingEvents = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (neighbourFragmentEntry?.fragmentId === fragmentEntry.fragmentId) {
|
|
||||||
log.log("hit #160, prevent fragment linking to itself", log.level.Warn);
|
|
||||||
neighbourFragmentEntry = null;
|
|
||||||
}
|
|
||||||
return {nonOverlappingEvents, neighbourFragmentEntry};
|
return {nonOverlappingEvents, neighbourFragmentEntry};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue