Handle Changeset missmatch gracefully

pull/55/head
Peter 'Pita' Martischka 2011-07-30 13:33:16 +01:00
parent 8a68007649
commit 325839f9fd
1 changed files with 7 additions and 3 deletions

View File

@ -415,9 +415,13 @@ function handleUserChanges(client, message)
function (callback)
{
var prevText = pad.text();
if (Changeset.oldLen(changeset) != prevText.length) {
throw "Can't apply USER_CHANGES "+changeset+" with oldLen "
+ Changeset.oldLen(changeset) + " to document of length " + prevText.length;
if (Changeset.oldLen(changeset) != prevText.length)
{
console.log("Can't apply USER_CHANGES "+changeset+" with oldLen " + Changeset.oldLen(changeset) + " to document of length " + prevText.length);
client.json.send({disconnect:"badChangeset"});
callback();
return;
}
var thisAuthor = sessioninfos[client.id].author;