feat: allow cleanup via REMOVE_DOWNLOAD env
This commit is contained in:
@@ -89,6 +89,19 @@ module.exports = async function server(req, res) {
|
|||||||
sent = true;
|
sent = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sent = true;
|
sent = true;
|
||||||
|
|
||||||
|
// clean up the download if told to
|
||||||
|
res.on('finish', () => {
|
||||||
|
const { REMOVE_DOWNLOAD } = process.env;
|
||||||
|
if (!REMOVE_DOWNLOAD) return;
|
||||||
|
|
||||||
|
const shouldRemove = REMOVE_DOWNLOAD === '1' || REMOVE_DOWNLOAD.toLowerCase() === 'true';
|
||||||
|
if (shouldRemove) {
|
||||||
|
logger.info('Removing local file:', dlFilepath);
|
||||||
|
fs.unlinkSync(dlFilepath);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user