fix some potentially fatal issues
This commit is contained in:
parent
6aedb21bae
commit
6247615e3d
|
@ -82,13 +82,18 @@ app.ws('/api/album', async (ws, req) => {
|
||||||
send(key, data) {
|
send(key, data) {
|
||||||
if (data.downloaded) {
|
if (data.downloaded) {
|
||||||
ws.send(JSON.stringify({key: 'download', data: data.downloadPath.replace(process.cwd(), '')}));
|
ws.send(JSON.stringify({key: 'download', data: data.downloadPath.replace(process.cwd(), '')}));
|
||||||
|
console.log('downloaded ' + data.downloadPath + ', deleting in 1hr')
|
||||||
setTimeout(() => {
|
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 */);
|
}, 1000 * 60 * 60 /* 1 hour */);
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.send(JSON.stringify({key, data}));
|
ws.send(JSON.stringify({key, data}));
|
||||||
console.log(`[${key}] ${inspect(data)}`);
|
//console.log(`[${key}] ${inspect(data)}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue