mirror of
https://github.com/Expand-sys/imapmove.com
synced 2025-12-17 05:52:15 +11:00
19 lines
522 B
JavaScript
19 lines
522 B
JavaScript
const { parentPort, workerData } = require("worker_threads");
|
|
let reply = await upload(data.source, data.id);
|
|
parentPort.on("message", (data) => {
|
|
parentPort.postMessage(reply);
|
|
});
|
|
|
|
async function download(source, id) {
|
|
try {
|
|
let { meta, content } = await source.download(i);
|
|
await content.pipe(
|
|
await fs.createWriteStream(path.resolve(__dirname, "./" + id))
|
|
);
|
|
} catch (e) {
|
|
console.log(e);
|
|
return `Failed to download ${id}`;
|
|
} finally {
|
|
return `Download Succeeded of ${id}`;
|
|
}
|
|
}
|