[FEATURE] Move Files Protocol

This commit is contained in:
Dunemask 2024-02-10 20:01:05 -07:00
parent 39369fe41a
commit c9361e6771
7 changed files with 52 additions and 79 deletions

View file

@ -86,12 +86,22 @@ export async function uploadServerItem(serverSpec, file) {
}).catch(handleError);
}
export async function getServerItem(serverSpec, writableStream) {
export async function getServerItem(serverSpec) {
const { path } = serverSpec;
const ds = new Transform({ transform: (c, e, cb) => cb(null, c) });
const ds = new Transform({ transform: (c, _e, cb) => cb(null, c) });
pathSecurityCheck(path);
const ftpTransfer = useServerFtp(serverSpec, async (c) => {
await c.downloadTo(ds, path);
}).catch(handleError);
return { ds, ftpTransfer };
}
export async function moveServerItems(serverSpec) {
const { destination, origin, files } = serverSpec;
useServerFtp(serverSpec, async (c) =>
Promise.all(
files.map((f) => c.rename(`${origin}/${f}`, `${destination}/${f}`)),
),
).catch(handleError);
return files;
}