From d3fd52d7215ca644a524d6f0b3c081be9df14e4b Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 23 Apr 2021 10:48:35 +0200 Subject: [PATCH] Handle corrupted cache in OO chainpad --- www/common/onlyoffice/inner.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 639e69d01..6f1ac6b2a 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -2528,6 +2528,18 @@ define([ toolbar.$drawer.append($properties); }; + var noCache = false; // Prevent reload loops + var onCorruptedCache = function () { + if (noCache) { + UI.errorLoadingScreen(Messages.unableToDisplay, false, function () { + common.gotoURL(''); + }); + } + noCache = true; + var sframeChan = common.getSframeChannel(); + sframeChan.event("EV_CORRUPTED_CACHE"); + }; + config.onReady = function (info) { if (APP.realtime !== info.realtime) { APP.realtime = info.realtime; @@ -2560,11 +2572,8 @@ define([ newDoc = !content.hashes || Object.keys(content.hashes).length === 0; } else if (!privateData.isNewFile) { // This is an empty doc but not a new file: error - // XXX clear cache before reloading - UI.errorLoadingScreen(Messages.unableToDisplay, false, function () { - common.gotoURL(''); - }); - throw new Error("Empty chainpad for a non-empty doc"); + onCorruptedCache(); + return void console.error("Empty chainpad for a non-empty doc"); } else { Title.updateTitle(Title.defaultTitle); }