From ac875763601f92eff8eeb227e3675170d22a84ae Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 26 Apr 2021 13:23:59 +0200 Subject: [PATCH] Never store invalid OO checkpoints --- www/common/onlyoffice/inner.js | 12 ++++++++++++ www/common/sframe-common-outer.js | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 1a84d4a41..5a720a60c 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -477,6 +477,18 @@ define([ var saveToServer = function () { if (APP.cantCheckpoint) { return; } // TOO_LARGE var text = getContent(); + text = undefined; + if (!text) { + setEditable(false, true); + sframeChan.query('Q_CLEAR_CACHE_CHANNELS', [ + 'chainpad', + content.channel, + ], function () {}); + UI.alert(Messages.realtime_unrecoverableError, function () { + common.gotoURL(); + }); + return; + } var blob = new Blob([text], {type: 'plain/text'}); var file = getFileType(); blob.name = (metadataMgr.getMetadataLazy().title || file.doc) + '.' + file.type; diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index dde533e9f..7190fb997 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -1533,6 +1533,16 @@ define([ sframeChan.on('Q_CLEAR_CACHE', function (data, cb) { Utils.Cache.clear(cb); }); + sframeChan.on('Q_CLEAR_CACHE_CHANNELS', function (channels, cb) { + if (!Array.isArray(channels)) { return void cb({error: "NOT_AN_ARRAY"}); } + nThen(function (waitFor) { + channels.forEach(function (chan) { + if (chan === "chainpad") { chan = secret.channel; } + console.error(chan); + Utils.Cache.clearChannel(chan, waitFor()); + }); + }).nThen(cb); + }); sframeChan.on('Q_PIN_GET_USAGE', function (teamId, cb) { Cryptpad.isOverPinLimit(teamId, function (err, overLimit, data) {