Merge branch 'sfBug' into staging

pull/1/head
yflory 5 years ago
commit 4ffb9dc635

@ -2054,6 +2054,10 @@ define([
var addSharedFolderHandler = function () {
store.sharedFolders = {};
store.handleSharedFolder = function (id, rt) {
if (!rt) {
delete store.sharedFolders[id];
return;
}
store.sharedFolders[id] = rt;
if (store.driveEvents) {
registerProxyEvents(rt.proxy, id);

@ -211,6 +211,9 @@ define([
// We can only hide it
sf.teams.forEach(function (obj) {
obj.store.manager.deprecateProxy(obj.id, secret.channel);
if (obj.store.handleSharedFolder) {
obj.store.handleSharedFolder(obj.id, null);
}
});
} catch (e) {}
delete allSharedFolders[secret.channel];
@ -252,9 +255,14 @@ define([
if (!sf) { return; }
var clients = sf.teams;
if (!Array.isArray(clients)) { return; }
// Remove the shared folder from the client's store and
// remove the client/team from our list
var idx;
clients.some(function (obj, i) {
if (obj.store.id === teamId) {
if (obj.store.handleSharedFolder) {
obj.store.handleSharedFolder(obj.id, null);
}
idx = i;
return true;
}

@ -164,6 +164,10 @@ define([
var handleSharedFolder = function (ctx, id, sfId, rt) {
var t = ctx.teams[id];
if (!t) { return; }
if (!rt) {
delete t.sharedFolders[sfId];
return;
}
t.sharedFolders[sfId] = rt;
registerChangeEvents(ctx, t, rt.proxy, sfId);
};

@ -52,6 +52,10 @@ define([
// Password may have changed
var deprecateProxy = function (Env, id, channel) {
if (Env.folders[id] && Env.folders[id].deleting) {
// Folder is being deleted by its owner, don't deprecate it
return;
}
if (Env.user.userObject.readOnly) {
// In a read-only team, we can't deprecate a shared folder
// Use a empty object with a deprecated flag...
@ -823,19 +827,38 @@ define([
var data = uo.isFile(el) ? uo.getFileData(el) : getSharedFolderData(Env, el);
chan = data.channel;
}
// If the pad was a shared folder, delete it too and leave it
var fId;
Object.keys(Env.user.proxy[UserObject.SHARED_FOLDERS] || {}).some(function (id) {
var sfData = Env.user.proxy[UserObject.SHARED_FOLDERS][id] || {};
if (sfData.channel === chan) {
fId = Number(id);
Env.folders[id].deleting = true;
return true;
}
});
Env.removeOwnedChannel(chan, function (obj) {
// If the error is that the file is already removed, nothing to
// report, it's a normal behavior (pad expired probably)
if (obj && obj.error && obj.error.code !== "ENOENT") {
// RPC may not be responding
// Send a report that can be handled manually
if (fId && Env.folders[fId] && Env.folders[fId].deleting) {
delete Env.folders[fId].deleting;
}
console.error(obj.error, chan);
Feedback.send('ERROR_DELETING_OWNED_PAD=' + chan + '|' + obj.error, true);
return void cb();
}
// No error: delete the pads and all its copies from our drive and shared folders
// No error: delete the pad and all its copies from our drive and shared folders
var ids = _findChannels(Env, [chan]);
// If the pad was a shared folder, delete it too and leave it
if (fId) {
ids.push(fId);
}
ids.forEach(function (id) {
var paths = findFile(Env, id);
var _resolved = _resolvePaths(Env, paths);

Loading…
Cancel
Save