refac
This commit is contained in:
@@ -334,6 +334,10 @@
|
|||||||
|
|
||||||
if (source === destination) return;
|
if (source === destination) return;
|
||||||
|
|
||||||
|
// Prevent moving a folder into itself or its own subtree
|
||||||
|
const sourceDir = source.endsWith('/') ? source : source + '/';
|
||||||
|
if (destFolder.startsWith(sourceDir)) return;
|
||||||
|
|
||||||
const result = await moveEntry(terminal.url, terminal.key, source, destination);
|
const result = await moveEntry(terminal.url, terminal.key, source, destination);
|
||||||
toast[result ? 'success' : 'error'](
|
toast[result ? 'success' : 'error'](
|
||||||
$i18n.t(result ? 'Moved {{name}}' : 'Failed to move {{name}}', { name: fileName })
|
$i18n.t(result ? 'Moved {{name}}' : 'Failed to move {{name}}', { name: fileName })
|
||||||
|
|||||||
@@ -51,6 +51,8 @@
|
|||||||
const data = JSON.parse(raw);
|
const data = JSON.parse(raw);
|
||||||
if (data.path) {
|
if (data.path) {
|
||||||
const destFolder = `${currentPath}${entry.name}/`;
|
const destFolder = `${currentPath}${entry.name}/`;
|
||||||
|
// Don't allow dropping a folder onto itself
|
||||||
|
if (data.path + '/' === destFolder || data.path === destFolder) return;
|
||||||
onMove(data.path, destFolder);
|
onMove(data.path, destFolder);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|||||||
Reference in New Issue
Block a user