fixes related to ownership in modals opened from the drive

pull/1/head^2
ansuz 3 years ago
parent d9d3859a30
commit a562bbc2e1

@ -18,6 +18,8 @@ define([
data.allowed = obj.allowed; data.allowed = obj.allowed;
data.rejected = obj.rejected; 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) { Modal.loadMetadata = function (Env, data, waitFor, redraw) {
Env.common.getPadMetadata({ Env.common.getPadMetadata({
channel: data.channel channel: data.channel
@ -35,6 +37,7 @@ define([
nThen(function (waitFor) { nThen(function (waitFor) {
var priv = common.getMetadataMgr().getPrivateData(); var priv = common.getMetadataMgr().getPrivateData();
var base = priv.origin; var base = priv.origin;
// this fetches attributes from your shared worker's memory
common.getPadAttribute('', waitFor(function (err, val) { common.getPadAttribute('', waitFor(function (err, val) {
if (err || !val) { if (err || !val) {
if (opts.access) { if (opts.access) {
@ -50,6 +53,14 @@ define([
} }
return; 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) { if (!val.fileType) {
delete val.owners; delete val.owners;
delete val.expire; delete val.expire;
@ -59,8 +70,10 @@ define([
if (data.roHref) { data.roHref = base + data.roHref; } if (data.roHref) { data.roHref = base + data.roHref; }
}), opts.href); }), opts.href);
if (opts.channel) { data.channel = opts.channel; }
// If this is a file, don't try to look for metadata // If this is a file, don't try to look for metadata
if (opts.channel && opts.channel.length > 32) { return; } if (opts.channel && opts.channel.length > 32) { return; }
// this fetches data from the server
Modal.loadMetadata(Env, data, waitFor); Modal.loadMetadata(Env, data, waitFor);
}).nThen(function () { }).nThen(function () {
if (opts.channel) { data.channel = opts.channel; } if (opts.channel) { data.channel = opts.channel; }

Loading…
Cancel
Save