handle errors when converting folders to shared folders

pull/1/head
ansuz 5 years ago
parent 7d583975b8
commit a368948fb6

@ -469,16 +469,19 @@ define([
// don't try to convert top-level elements (trash, root, etc) to shared-folders
// TODO also validate that you're in root (not templates, etc)
if (data.path.length <= 1) {
// XXX call back with error and abort nThen
return;
return void cb({
error: 'E_INVAL_PATH',
});
}
if (_isInSharedFolder(Env, path)) {
// XXX call back with error and abort nThen
return;
return void cb({
error: 'E_INVAL_NESTING',
});
}
if (Env.user.userObject.hasSubSharedFolder(folderElement)) {
// XXX call back with error and abort nThen
return;
return void cb({
error: 'E_INVAL_NESTING',
});
}
var parentPath = path.slice(0, -1);
var parentFolder = Env.user.userObject.find(parentPath);
@ -489,12 +492,13 @@ define([
_addSharedFolder(Env, {
path: parentPath,
name: folderName,
owned: true, // FIXME hardcoded preference
password: '', // FIXME hardcoded preference
owned: true, // XXX FIXME hardcoded preference
password: '', // XXX FIXME hardcoded preference
}, waitFor(function (id) {
// _addSharedFolder can be an id or an error
if (typeof(id) === 'object' && id && id.error) {
// XXX FIXME handle error
waitFor.abort();
return void cb(id);
} else {
SFId = id;
}
@ -502,9 +506,10 @@ define([
}).nThen(function (waitFor) {
// move everything from folder to SF
if (!SFId) {
// XXX FIXME callback does not indicate that there is an error
// XXX FIXME does not abort nThen chain
return void cb();
waitFor.abort();
return void cb({
error: 'E_NO_ID'
});
}
var paths = [];
for (var el in folderElement) {
@ -520,6 +525,13 @@ define([
return true;
}
});
if (!SFKey) {
waitFor.abort();
return void cb({
error: 'E_NO_KEY'
});
}
var newPath = parentPath.concat(SFKey).concat(UserObject.ROOT);
_move(Env, {
paths: paths,

Loading…
Cancel
Save