refac
This commit is contained in:
1 parent
24370d5c40
commit
3841e85abb
4 files changed
+112
-50
No files matched your search
@@ -19,6 +19,8 @@
|
||||
listFiles,
|
||||
readFile,
|
||||
downloadFileBlob,
|
||||
downloadDirectoryArchive,
|
||||
downloadMultipleAsZip,
|
||||
uploadToTerminal,
|
||||
createDirectory,
|
||||
deleteEntry,
|
||||
@@ -403,7 +405,11 @@
|
||||
const terminal = selectedTerminal;
|
||||
if (!terminal) return;
|
||||
|
||||
const result = await downloadFileBlob(terminal.url, terminal.key, path);
|
||||
// Directories end with '/' — download as ZIP archive
|
||||
const isDir = path.endsWith('/');
|
||||
const result = isDir
|
||||
? await downloadDirectoryArchive(terminal.url, terminal.key, path.replace(/\/$/, ''))
|
||||
: await downloadFileBlob(terminal.url, terminal.key, path);
|
||||
if (!result) return;
|
||||
const url = URL.createObjectURL(result.blob);
|
||||
const a = document.createElement('a');
|
||||
@@ -644,10 +650,24 @@
|
||||
const terminal = selectedTerminal;
|
||||
if (!terminal) return;
|
||||
|
||||
const filePaths = [...selectedEntries].filter((p) => !p.endsWith('/'));
|
||||
for (const p of filePaths) {
|
||||
await downloadFile(p);
|
||||
const paths = [...selectedEntries].map((p) => p.replace(/\/$/, ''));
|
||||
if (paths.length === 0) return;
|
||||
|
||||
// Single item — use the regular downloadFile path
|
||||
if (paths.length === 1) {
|
||||
await downloadFile([...selectedEntries][0]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Multiple items — bundle into a single ZIP
|
||||
const result = await downloadMultipleAsZip(terminal.url, terminal.key, paths);
|
||||
if (!result) return;
|
||||
const url = URL.createObjectURL(result.blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = result.filename;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
// Escape to clear selection
|
||||
|
||||
Reference in new issue
Block a user