mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 08:26:16 -04:00
PadMessageHandler: Accept retransmissions of USER_CHANGES
This commit is contained in:
parent
a370cfa5c6
commit
cff089e54e
3 changed files with 10 additions and 13 deletions
|
@ -615,19 +615,15 @@ const handleUserChanges = async (socket, message) => {
|
|||
// Update the changeset so that it can be applied to the latest revision.
|
||||
while (r < pad.getHeadRevisionNumber()) {
|
||||
r++;
|
||||
|
||||
const c = await pad.getRevisionChangeset(r);
|
||||
|
||||
const {changeset: c, meta: {author: authorId}} = await pad.getRevision(r);
|
||||
if (changeset === c && thisSession.author === authorId) {
|
||||
// Assume this is a retransmission of an already applied changeset.
|
||||
rebasedChangeset = Changeset.identity(Changeset.unpack(changeset).oldLen);
|
||||
}
|
||||
// At this point, both "c" (from the pad) and "changeset" (from the
|
||||
// client) are relative to revision r - 1. The follow function
|
||||
// rebases "changeset" so that it is relative to revision r
|
||||
// and can be applied after "c".
|
||||
|
||||
// a changeset can be based on an old revision with the same changes in it
|
||||
// prevent eplite from accepting it TODO: better send the client a NEW_CHANGES
|
||||
// of that revision
|
||||
if (baseRev + 1 === r && c === changeset) throw new Error('Changeset already accepted');
|
||||
|
||||
rebasedChangeset = Changeset.follow(c, rebasedChangeset, false, pad.pool);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue