Fix race condition between RPC and restricted shared folders

pull/1/head
yflory 4 years ago
parent e874e49441
commit 34b2eb2e33

@ -2622,22 +2622,28 @@ define([
// "cb" is wrapped in Util.once() and may have already been called // "cb" is wrapped in Util.once() and may have already been called
// if we have a local cache // if we have a local cache
var onReady = function (clientId, returned, cb) { var onReady = function (clientId, returned, cb) {
console.error('READY');
store.ready = true; store.ready = true;
var proxy = store.proxy; var proxy = store.proxy;
var manager = store.manager; var manager = store.manager;
var userObject = store.userObject; var userObject = store.userObject;
nThen(function (waitFor) { nThen(function (waitFor) {
if (manager) { return; }
if (!proxy.settings) { proxy.settings = NEW_USER_SETTINGS; } if (!proxy.settings) { proxy.settings = NEW_USER_SETTINGS; }
if (!proxy.friends_pending) { proxy.friends_pending = {}; } if (!proxy.friends_pending) { proxy.friends_pending = {}; }
onCacheReady(clientId, waitFor());
manager = store.manager; // Call onCacheReady if the manager is not yet defined
userObject = store.userObject; if (!manager) {
}).nThen(function (waitFor) { onCacheReady(clientId, waitFor());
manager = store.manager;
userObject = store.userObject;
}
// Initialize RPC in parallel of onCacheReady in case a shared folder
// is RESTRICTED and requires RPC authentication
initAnonRpc(null, null, waitFor()); initAnonRpc(null, null, waitFor());
initRpc(null, null, waitFor()); initRpc(null, null, waitFor());
// Update loading progress
postMessage(clientId, 'LOADING_DRIVE', { postMessage(clientId, 'LOADING_DRIVE', {
type: 'migrate', type: 'migrate',
progress: 0 progress: 0

@ -351,10 +351,9 @@ define([
var team; var team;
if (!ctx.store.proxy.teams[id]) { return; } if (!ctx.store.proxy.teams[id]) { return; }
nThen(function (waitFor) { nThen(function (waitFor) {
if (ctx.cache[id]) { return; }
onCacheReady(ctx, id, lm, roster, keys, cId, waitFor()); onCacheReady(ctx, id, lm, roster, keys, cId, waitFor());
}).nThen(function (waitFor) { team = ctx.teams[id] || ctx.cache[id];
team = ctx.teams[id];
// Init Team RPC // Init Team RPC
if (!keys.drive.edPrivate) { return; } if (!keys.drive.edPrivate) { return; }
initRpc(ctx, team, keys.drive, waitFor(function () {})); initRpc(ctx, team, keys.drive, waitFor(function () {}));

Loading…
Cancel
Save