Fix and reenable folder to SF conversion

pull/1/head
yflory 5 years ago
parent 403867d4cd
commit 09076f39ff

@ -1204,8 +1204,6 @@ define([
hide.push('collapseall'); hide.push('collapseall');
} }
containsFolder = true; containsFolder = true;
hide.push('share'); // XXX CONVERT
hide.push('savelocal'); // XXX CONVERT
hide.push('openro'); hide.push('openro');
hide.push('openincode'); hide.push('openincode');
hide.push('properties'); hide.push('properties');
@ -4054,8 +4052,7 @@ define([
if (manager.isFolder(el) && !manager.isSharedFolder(el)) { // Folder if (manager.isFolder(el) && !manager.isSharedFolder(el)) { // Folder
// if folder is inside SF // if folder is inside SF
return UI.warn('ERROR: Temporarily disabled'); // XXX CONVERT if (manager.isInSharedFolder(paths[0].path)) {
/*if (manager.isInSharedFolder(paths[0].path)) {
return void UI.alert(Messages.convertFolderToSF_SFParent); return void UI.alert(Messages.convertFolderToSF_SFParent);
} }
// if folder already contains SF // if folder already contains SF
@ -4085,7 +4082,7 @@ define([
var owned = Util.isChecked($(convertContent).find('#cp-upload-owned')); var owned = Util.isChecked($(convertContent).find('#cp-upload-owned'));
manager.convertFolderToSharedFolder(paths[0].path, owned, password, refresh); manager.convertFolderToSharedFolder(paths[0].path, owned, password, refresh);
}); });
}*/ }
} else { // File } else { // File
var sf = manager.isSharedFolder(el); var sf = manager.isSharedFolder(el);
data = sf ? manager.getSharedFolderData(el) : manager.getFileData(el); data = sf ? manager.getSharedFolderData(el) : manager.getFileData(el);

@ -587,14 +587,10 @@ define([
// 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({ var path = data.path;
error: 'DISABLED'
}); // XXX CONVERT
/*var path = data.path;
var folderElement = Env.user.userObject.find(path); var folderElement = Env.user.userObject.find(path);
// don't try to convert top-level elements (trash, root, etc) to shared-folders // 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 (path.length <= 1 || path[0] !== UserObject.ROOT) {
if (data.path.length <= 1) {
return void cb({ return void cb({
error: 'E_INVAL_PATH', error: 'E_INVAL_PATH',
}); });
@ -664,6 +660,21 @@ define([
newPath: newPath, newPath: newPath,
copy: false, copy: false,
}, waitFor()); }, waitFor());
}).nThen(function (waitFor) {
// Move the owned pads from the old folder to root
var paths = [];
Object.keys(folderElement).forEach(function (el) {
if (!Env.user.userObject.isFile(folderElement[el])) { return; }
var data = Env.user.userObject.getFileData(folderElement[el]);
if (!data || !_ownedByMe(Env, data.owners)) { return; }
// This is an owned pad: move it to ROOT before deleting the initial folder
paths.push(path.concat(el));
});
_move(Env, {
paths: paths,
newPath: [UserObject.ROOT],
copy: false,
}, waitFor());
}).nThen(function () { }).nThen(function () {
// migrate metadata // migrate metadata
var sharedFolderElement = Env.user.proxy[UserObject.SHARED_FOLDERS][SFId]; var sharedFolderElement = Env.user.proxy[UserObject.SHARED_FOLDERS][SFId];
@ -680,7 +691,7 @@ define([
Env.user.userObject.delete([path], function () { Env.user.userObject.delete([path], function () {
cb(); cb();
}); });
});*/ });
}; };
// Delete permanently some pads or folders // Delete permanently some pads or folders

Loading…
Cancel
Save