|
|
@ -23,6 +23,12 @@ define([
|
|
|
|
// Only in outer
|
|
|
|
// Only in outer
|
|
|
|
userObject.fixFiles();
|
|
|
|
userObject.fixFiles();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proxy.metadata && proxy.metadata.title) {
|
|
|
|
|
|
|
|
var sf = Env.user.proxy[UserObject.SHARED_FOLDERS][id];
|
|
|
|
|
|
|
|
if (sf) {
|
|
|
|
|
|
|
|
sf.lastTitle = proxy.metadata.title;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Env.folders[id] = {
|
|
|
|
Env.folders[id] = {
|
|
|
|
proxy: proxy,
|
|
|
|
proxy: proxy,
|
|
|
|
userObject: userObject,
|
|
|
|
userObject: userObject,
|
|
|
@ -39,6 +45,12 @@ define([
|
|
|
|
delete Env.folders[id];
|
|
|
|
delete Env.folders[id];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Password may have changed
|
|
|
|
|
|
|
|
var deprecateProxy = function (Env, id, channel) {
|
|
|
|
|
|
|
|
Env.unpinPads([channel], function () {});
|
|
|
|
|
|
|
|
Env.user.userObject.deprecateSharedFolder(id);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Tools
|
|
|
|
Tools
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -447,6 +459,11 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
// 2b. load the proxy
|
|
|
|
// 2b. load the proxy
|
|
|
|
Env.loadSharedFolder(id, folderData, waitFor(function (rt, metadata) {
|
|
|
|
Env.loadSharedFolder(id, folderData, waitFor(function (rt, metadata) {
|
|
|
|
|
|
|
|
if (!rt) {
|
|
|
|
|
|
|
|
waitFor.abort();
|
|
|
|
|
|
|
|
return void cb({ error: 'EDELETED' });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!rt.proxy.metadata) { // Creating a new shared folder
|
|
|
|
if (!rt.proxy.metadata) { // Creating a new shared folder
|
|
|
|
rt.proxy.metadata = { title: data.name || Messages.fm_newFolder };
|
|
|
|
rt.proxy.metadata = { title: data.name || Messages.fm_newFolder };
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -456,7 +473,7 @@ define([
|
|
|
|
if (metadata.owners) { fData.owners = metadata.owners; }
|
|
|
|
if (metadata.owners) { fData.owners = metadata.owners; }
|
|
|
|
if (metadata.expire) { fData.expire = +metadata.expire; }
|
|
|
|
if (metadata.expire) { fData.expire = +metadata.expire; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}), !Boolean(data.folderData));
|
|
|
|
}).nThen(function () {
|
|
|
|
}).nThen(function () {
|
|
|
|
Env.onSync(function () {
|
|
|
|
Env.onSync(function () {
|
|
|
|
cb(id);
|
|
|
|
cb(id);
|
|
|
@ -464,6 +481,42 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _restoreSharedFolder = function (Env, _data, cb) {
|
|
|
|
|
|
|
|
var fId = _data.id;
|
|
|
|
|
|
|
|
var newPassword = _data.password;
|
|
|
|
|
|
|
|
var temp = Util.find(Env, ['user', 'proxy', UserObject.SHARED_FOLDERS_TEMP]);
|
|
|
|
|
|
|
|
var data = temp && temp[fId];
|
|
|
|
|
|
|
|
if (!data) { return void cb({ error: 'EINVAL' }); }
|
|
|
|
|
|
|
|
if (!Env.Store) { return void cb({ error: 'ESTORE' }); }
|
|
|
|
|
|
|
|
var href = Env.user.userObject.getHref ? Env.user.userObject.getHref(data) : data.href;
|
|
|
|
|
|
|
|
var isNew = false;
|
|
|
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
|
|
|
|
Env.Store.isNewChannel(null, {
|
|
|
|
|
|
|
|
href: href,
|
|
|
|
|
|
|
|
password: newPassword
|
|
|
|
|
|
|
|
}, waitFor(function (obj) {
|
|
|
|
|
|
|
|
if (!obj || obj.error) {
|
|
|
|
|
|
|
|
isNew = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
isNew = obj.isNew;
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
|
|
|
if (isNew) {
|
|
|
|
|
|
|
|
return void cb({ error: 'ENOTFOUND' });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
data.password = newPassword;
|
|
|
|
|
|
|
|
_addSharedFolder(Env, {
|
|
|
|
|
|
|
|
path: ['root'],
|
|
|
|
|
|
|
|
folderData: data,
|
|
|
|
|
|
|
|
}, function () {
|
|
|
|
|
|
|
|
delete temp[fId];
|
|
|
|
|
|
|
|
Env.onSync(cb);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// convert a folder to a Shared Folder
|
|
|
|
// convert a folder to a Shared Folder
|
|
|
|
var _convertFolderToSharedFolder = function (Env, data, cb) {
|
|
|
|
var _convertFolderToSharedFolder = function (Env, data, cb) {
|
|
|
|
return void cb({
|
|
|
|
return void cb({
|
|
|
@ -570,6 +623,13 @@ define([
|
|
|
|
return void cb({error: 'E_NOTFOUND'});
|
|
|
|
return void cb({error: 'E_NOTFOUND'});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Deleted or password changed for a shared folder
|
|
|
|
|
|
|
|
if (data.paths.length === 1 && data.paths[0][0] === UserObject.SHARED_FOLDERS_TEMP) {
|
|
|
|
|
|
|
|
var temp = Util.find(Env, ['user', 'proxy', UserObject.SHARED_FOLDERS_TEMP]);
|
|
|
|
|
|
|
|
delete temp[data.paths[0][1]];
|
|
|
|
|
|
|
|
return void Env.onSync(cb);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var toUnpin = [];
|
|
|
|
var toUnpin = [];
|
|
|
|
var ownedRemoved;
|
|
|
|
var ownedRemoved;
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
nThen(function (waitFor) {
|
|
|
@ -666,6 +726,7 @@ define([
|
|
|
|
var el = Env.user.userObject.find(resolved.path);
|
|
|
|
var el = Env.user.userObject.find(resolved.path);
|
|
|
|
if (Env.user.userObject.isSharedFolder(el) && Env.folders[el]) {
|
|
|
|
if (Env.user.userObject.isSharedFolder(el) && Env.folders[el]) {
|
|
|
|
Env.folders[el].proxy.metadata.title = data.newName;
|
|
|
|
Env.folders[el].proxy.metadata.title = data.newName;
|
|
|
|
|
|
|
|
Env.user.proxy[UserObject.SHARED_FOLDERS][el].lastTitle = data.value;
|
|
|
|
return void cb();
|
|
|
|
return void cb();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -699,6 +760,8 @@ define([
|
|
|
|
_addFolder(Env, data, cb); break;
|
|
|
|
_addFolder(Env, data, cb); break;
|
|
|
|
case 'addSharedFolder':
|
|
|
|
case 'addSharedFolder':
|
|
|
|
_addSharedFolder(Env, data, cb); break;
|
|
|
|
_addSharedFolder(Env, data, cb); break;
|
|
|
|
|
|
|
|
case 'restoreSharedFolder':
|
|
|
|
|
|
|
|
_restoreSharedFolder(Env, data, cb); break;
|
|
|
|
case 'convertFolderToSharedFolder':
|
|
|
|
case 'convertFolderToSharedFolder':
|
|
|
|
_convertFolderToSharedFolder(Env, data, cb); break;
|
|
|
|
_convertFolderToSharedFolder(Env, data, cb); break;
|
|
|
|
case 'delete':
|
|
|
|
case 'delete':
|
|
|
@ -925,6 +988,7 @@ define([
|
|
|
|
pinPads: data.pin,
|
|
|
|
pinPads: data.pin,
|
|
|
|
unpinPads: data.unpin,
|
|
|
|
unpinPads: data.unpin,
|
|
|
|
onSync: data.onSync,
|
|
|
|
onSync: data.onSync,
|
|
|
|
|
|
|
|
Store: data.Store,
|
|
|
|
loadSharedFolder: data.loadSharedFolder,
|
|
|
|
loadSharedFolder: data.loadSharedFolder,
|
|
|
|
cfg: uoConfig,
|
|
|
|
cfg: uoConfig,
|
|
|
|
edPublic: data.edPublic,
|
|
|
|
edPublic: data.edPublic,
|
|
|
@ -947,6 +1011,7 @@ define([
|
|
|
|
// Manager
|
|
|
|
// Manager
|
|
|
|
addProxy: callWithEnv(addProxy),
|
|
|
|
addProxy: callWithEnv(addProxy),
|
|
|
|
removeProxy: callWithEnv(removeProxy),
|
|
|
|
removeProxy: callWithEnv(removeProxy),
|
|
|
|
|
|
|
|
deprecateProxy: callWithEnv(deprecateProxy),
|
|
|
|
addSharedFolder: callWithEnv(_addSharedFolder),
|
|
|
|
addSharedFolder: callWithEnv(_addSharedFolder),
|
|
|
|
// Drive
|
|
|
|
// Drive
|
|
|
|
command: callWithEnv(onCommand),
|
|
|
|
command: callWithEnv(onCommand),
|
|
|
@ -1016,6 +1081,15 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, cb);
|
|
|
|
}, cb);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var restoreSharedFolderInner = function (Env, fId, password, cb) {
|
|
|
|
|
|
|
|
return void Env.sframeChan.query("Q_DRIVE_USEROBJECT", {
|
|
|
|
|
|
|
|
cmd: "restoreSharedFolder",
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
|
|
|
id: fId,
|
|
|
|
|
|
|
|
password: password
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, cb);
|
|
|
|
|
|
|
|
};
|
|
|
|
var convertFolderToSharedFolderInner = function (Env, path, owned, password, cb) {
|
|
|
|
var convertFolderToSharedFolderInner = function (Env, path, owned, password, cb) {
|
|
|
|
return void Env.sframeChan.query("Q_DRIVE_USEROBJECT", {
|
|
|
|
return void Env.sframeChan.query("Q_DRIVE_USEROBJECT", {
|
|
|
|
cmd: "convertFolderToSharedFolder",
|
|
|
|
cmd: "convertFolderToSharedFolder",
|
|
|
@ -1228,6 +1302,7 @@ define([
|
|
|
|
emptyTrash: callWithEnv(emptyTrashInner),
|
|
|
|
emptyTrash: callWithEnv(emptyTrashInner),
|
|
|
|
addFolder: callWithEnv(addFolderInner),
|
|
|
|
addFolder: callWithEnv(addFolderInner),
|
|
|
|
addSharedFolder: callWithEnv(addSharedFolderInner),
|
|
|
|
addSharedFolder: callWithEnv(addSharedFolderInner),
|
|
|
|
|
|
|
|
restoreSharedFolder: callWithEnv(restoreSharedFolderInner),
|
|
|
|
convertFolderToSharedFolder: callWithEnv(convertFolderToSharedFolderInner),
|
|
|
|
convertFolderToSharedFolder: callWithEnv(convertFolderToSharedFolderInner),
|
|
|
|
delete: callWithEnv(deleteInner),
|
|
|
|
delete: callWithEnv(deleteInner),
|
|
|
|
restore: callWithEnv(restoreInner),
|
|
|
|
restore: callWithEnv(restoreInner),
|
|
|
|