fix some potentially fatal issues

This commit is contained in:
Jill 2021-10-19 21:18:50 +00:00
parent 6aedb21bae
commit 6247615e3d
1 changed files with 7 additions and 2 deletions

View File

@ -82,13 +82,18 @@ app.ws('/api/album', async (ws, req) => {
send(key, data) {
if (data.downloaded) {
ws.send(JSON.stringify({key: 'download', data: data.downloadPath.replace(process.cwd(), '')}));
console.log('downloaded ' + data.downloadPath + ', deleting in 1hr')
setTimeout(() => {
fs.unlinkSync(data.downloadPath);
try {
fs.unlinkSync(data.downloadPath);
} catch(err) {
console.log('tried to delete ' + data.downloadPath + ', but failed? its likely already gone')
}
}, 1000 * 60 * 60 /* 1 hour */);
}
ws.send(JSON.stringify({key, data}));
console.log(`[${key}] ${inspect(data)}`);
//console.log(`[${key}] ${inspect(data)}`);
}
};