From a562bbc2e1a5a96ed3c26dae98d54f5521107fe5 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 13 Apr 2022 16:07:00 +0530 Subject: [PATCH] fixes related to ownership in modals opened from the drive --- www/common/inner/common-modal.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/www/common/inner/common-modal.js b/www/common/inner/common-modal.js index 7bbe7bdbc..6d34747e2 100644 --- a/www/common/inner/common-modal.js +++ b/www/common/inner/common-modal.js @@ -18,6 +18,8 @@ define([ data.allowed = obj.allowed; data.rejected = obj.rejected; }; + // trying to get data from server + // should be authoritative, so override whatever you have in memory Modal.loadMetadata = function (Env, data, waitFor, redraw) { Env.common.getPadMetadata({ channel: data.channel @@ -35,6 +37,7 @@ define([ nThen(function (waitFor) { var priv = common.getMetadataMgr().getPrivateData(); var base = priv.origin; + // this fetches attributes from your shared worker's memory common.getPadAttribute('', waitFor(function (err, val) { if (err || !val) { if (opts.access) { @@ -50,6 +53,14 @@ define([ } return; } + // we delete owners because this query to the worker + // is concurrent with the call to the server. + // we shouldn't trust local information about ownership or expiration + // over that provided by the server, so we simply ignore the local version. + // this could be made more correct at the expense of some latency by not + // running the two queries concurrently, but we consider responsiveness + // more of a priority I guess. Maybe reconsider that if you find + // that this causes any bugs. if (!val.fileType) { delete val.owners; delete val.expire; @@ -59,8 +70,10 @@ define([ if (data.roHref) { data.roHref = base + data.roHref; } }), opts.href); + if (opts.channel) { data.channel = opts.channel; } // If this is a file, don't try to look for metadata if (opts.channel && opts.channel.length > 32) { return; } + // this fetches data from the server Modal.loadMetadata(Env, data, waitFor); }).nThen(function () { if (opts.channel) { data.channel = opts.channel; }