mirror of
https://github.com/Expand-sys/imapmove.com
synced 2025-12-17 05:52:15 +11:00
21 lines
557 B
JavaScript
21 lines
557 B
JavaScript
const { parentPort, workerData } = require("worker_threads");
|
|
const fs = require("fs");
|
|
let reply = await upload(data.dest, data.id);
|
|
parentPort.on("message", (data) => {
|
|
parentPort.postMessage(reply);
|
|
});
|
|
|
|
async function upload(dest, id) {
|
|
try {
|
|
const buf = await Buffer.from(
|
|
await fs.readFileSync(path.resolve(__dirname, "./" + id))
|
|
);
|
|
await dest.append("INBOX", buf);
|
|
fs.rmSync(path.resolve(__dirname, "./" + id));
|
|
} catch (e) {
|
|
console.log(e);
|
|
return `Failed ${id}`;
|
|
} finally {
|
|
return `Uploaded ${id}`;
|
|
}
|
|
}
|