Merge pull request #2297 from cryptpad/fix-oo-history-corruption

Fix oo history corruption
This commit is contained in:
yflory 2026-05-19 15:06:19 +02:00 committed by GitHub
commit a3db5b6aa1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 10 deletions

View File

@ -98,7 +98,7 @@ main() {
rm -rf "$OO_DIR/v8/web-apps/apps/spreadsheeteditor/main/resources/help"
rm -rf "$OO_DIR/v8/web-apps/apps/common/main/resources/help/"
;;
v9) install_version v9 v9.2.0.119+5 1f1184fb04cf72a7eb2a49a9740074b5419486c79e1fd713e1f8c09b8594a826050ae941fed6ac6a96807ba73cc751d7c807bd7e6b73de9e4f8e74cd5ed04cfa ;;
v9) install_version v9 v9.3.0.140+2 fedf1af4c3b061f6afadbc231cee7f06d15dd1a5e82db3c5f1e9739b7ddf5b5b38825f3ec3da5e92d7ed6ad1d944c11b9f83875cc5fb67bde4f9c9b1434579d8 ;;
x2t) install_x2t v7.3+1 ab0c05b0e4c81071acea83f0c6a8e75f5870c360ec4abc4af09105dd9b52264af9711ec0b7020e87095193ac9b6e20305e446f2321a541f743626a598e5318c1 ;;
*)
echo "Unknown version: $version"

View File

@ -102,7 +102,7 @@ define([
hashes: {},
ids: {},
mediasSources: {},
version: privateData.ooForceVersion ? Number(privateData.ooForceVersion) : OOCurrentVersion.currentVersionNumber
version: privateData.ooForceVersion ? Number(privateData.ooForceVersion) : OOCurrentVersion.currentVersionNumber,
};
var oldHashes = {};
var oldIds = {};
@ -565,6 +565,7 @@ define([
isLockedModal.modal = UI.openCustomModal(isLockedModal.content);
}
myUniqueOOId = undefined;
myIndex = undefined;
setMyId();
if (APP.docEditor) { APP.docEditor.destroyEditor(); } // Kill the old editor
@ -2206,6 +2207,11 @@ define([
}];
common.checkTrimHistory(channels);
}
content.debug = content.debug ?? {};
content.debug.idCollision = content.debug.idCollision ?? false;
APP.onLocal();
console.log("OO ready");
};
@ -2628,12 +2634,25 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
makeChannel();
return;
}
const onCorruptionWarning = Util.once((id) => {
console.log('id collision in document', id);
if (content?.debug?.idCollision !== undefined // No feedback for old documents
&& content?.debug?.idCollision === false) { // Send feedback only once
Feedback.send(`channel=${content.channel}&OFFICE_DOCUMENT_ID_COLLISION`, true);
content.debug = content.debug ?? {};
content.debug.idCollision = true;
APP.onLocal();
}
});
APP.docEditor.connectMockServer({
onMessage: fromOOHandler,
getParticipants: getParticipants,
onAuth: onAuth,
getImageURL: getImageURL,
getInitialChanges: getInitialChanges,
onCorruptionWarning: onCorruptionWarning,
});
};
@ -2998,7 +3017,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
pinImages();
};
const loadCp = async function (cp, keepQueue) {
const loadCheckpoint = async function (cp, keepQueue) {
if (!isLockedModal.modal) {
isLockedModal.modal = UI.openCustomModal(isLockedModal.content);
}
@ -3018,7 +3037,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
var loadHistoryCp = function (cp, keepQueue) {
APP.history = true;
APP.stopHistory = false;
loadCp(cp, keepQueue);
loadCheckpoint(cp, keepQueue);
};
var loadTemplate = function (href, pw, parsed) {
@ -3068,7 +3087,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
});
ooChannel.historyLastHash = ooChannel.lastHash;
ooChannel.currentIndex = ooChannel.cpIndex;
loadCp(lastCp, true);
loadCheckpoint(lastCp, true);
});
};
@ -3239,7 +3258,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
};
var onCheckpoint = function (cp) {
// We want to load a checkpoint:
loadCp(cp, true);
loadCheckpoint(cp, true);
};
var onPatchBack = function (cp, msgs) {
APP.history = true;
@ -3259,10 +3278,10 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
});
ooChannel.queue = msgsFormatted;
setTimeout(function () {
loadCp(cp, true);
loadCheckpoint(cp, true);
}, 200);
} else {
loadCp(cp);
loadCheckpoint(cp);
}
};
var docType = function() {
@ -3283,7 +3302,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
// Fill the queue and then load the last CP
rtChannel.getHistory(function () {
var lastCp = getLastCp();
loadCp(lastCp, true);
loadCheckpoint(lastCp, true);
});
};
@ -3341,7 +3360,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
onPatch: onPatch,
onPatchBack: onPatchBack,
docType: docType,
loadCp: loadCp,
loadCp: loadCheckpoint,
loadHistoryCp: loadHistoryCp,
onCheckpoint: onCheckpoint,
onRevert: commit,