|
|
@ -795,20 +795,23 @@ define([
|
|
|
|
// Delete permanently some pads or folders
|
|
|
|
// Delete permanently some pads or folders
|
|
|
|
var _deleteOwned = function (Env, data, cb) {
|
|
|
|
var _deleteOwned = function (Env, data, cb) {
|
|
|
|
data = data || {};
|
|
|
|
data = data || {};
|
|
|
|
var resolved = _resolvePaths(Env, data.paths);
|
|
|
|
var resolved = _resolvePaths(Env, data.paths || []);
|
|
|
|
if (!resolved.main.length && !Object.keys(resolved.folders).length) {
|
|
|
|
if (!data.channel && !resolved.main.length && !Object.keys(resolved.folders).length) {
|
|
|
|
return void cb({error: 'E_NOTFOUND'});
|
|
|
|
return void cb({error: 'E_NOTFOUND'});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var toDelete = {
|
|
|
|
var toDelete = {
|
|
|
|
main: [],
|
|
|
|
main: [],
|
|
|
|
folders: {}
|
|
|
|
folders: {}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var todo = function (id, uo, p, _cb) {
|
|
|
|
var todo = function (channel, uo, p, _cb) {
|
|
|
|
var cb = Util.once(Util.mkAsync(_cb));
|
|
|
|
var cb = Util.once(Util.mkAsync(_cb));
|
|
|
|
var el = uo.find(p);
|
|
|
|
var chan = channel;
|
|
|
|
if (!uo.isFile(el) && !uo.isSharedFolder(el)) { return; }
|
|
|
|
if (!chan && uo) {
|
|
|
|
var data = uo.isFile(el) ? uo.getFileData(el) : getSharedFolderData(Env, el);
|
|
|
|
var el = uo.find(p);
|
|
|
|
var chan = data.channel;
|
|
|
|
if (!uo.isFile(el) && !uo.isSharedFolder(el)) { return; }
|
|
|
|
|
|
|
|
var data = uo.isFile(el) ? uo.getFileData(el) : getSharedFolderData(Env, el);
|
|
|
|
|
|
|
|
chan = data.channel;
|
|
|
|
|
|
|
|
}
|
|
|
|
Env.removeOwnedChannel(chan, function (obj) {
|
|
|
|
Env.removeOwnedChannel(chan, function (obj) {
|
|
|
|
// If the error is that the file is already removed, nothing to
|
|
|
|
// If the error is that the file is already removed, nothing to
|
|
|
|
// report, it's a normal behavior (pad expired probably)
|
|
|
|
// report, it's a normal behavior (pad expired probably)
|
|
|
@ -840,13 +843,16 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
nThen(function (w) {
|
|
|
|
nThen(function (w) {
|
|
|
|
// Delete owned pads from the server
|
|
|
|
// Delete owned pads from the server
|
|
|
|
|
|
|
|
if (data.channel) {
|
|
|
|
|
|
|
|
todo(data.channel, null, null, w());
|
|
|
|
|
|
|
|
}
|
|
|
|
resolved.main.forEach(function (p) {
|
|
|
|
resolved.main.forEach(function (p) {
|
|
|
|
todo(null, Env.user.userObject, p, w());
|
|
|
|
todo(null, Env.user.userObject, p, w());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
Object.keys(resolved.folders).forEach(function (id) {
|
|
|
|
Object.keys(resolved.folders).forEach(function (id) {
|
|
|
|
var uo = Env.folders[id].userObject;
|
|
|
|
var uo = Env.folders[id].userObject;
|
|
|
|
resolved.folders[id].forEach(function (p) {
|
|
|
|
resolved.folders[id].forEach(function (p) {
|
|
|
|
todo(id, uo, p, w());
|
|
|
|
todo(null, uo, p, w());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).nThen(function () {
|
|
|
|
}).nThen(function () {
|
|
|
|