diff --git a/server/portal_server.js b/server/portal_server.js index 3029f5d4..5b2585f2 100644 --- a/server/portal_server.js +++ b/server/portal_server.js @@ -63,19 +63,18 @@ app.get('/assets/download/:id', (req, res) => { 'Content-Type': 'application/octet-stream', 'Content-Length': contentLength }); - }); + let file_stream = storage.get(id); - let file_stream = storage.get(id); - - file_stream.on(notLocalHost ? 'finish' : 'close', () => { - storage.forceDelete(id).then(err => { - if (!err) { - console.log('Deleted.'); - } + file_stream.on(notLocalHost ? 'finish' : 'close', () => { + storage.forceDelete(id).then(err => { + if (!err) { + console.log('Deleted.'); + } + }); }); - }); - file_stream.pipe(res); + file_stream.pipe(res); + }); }) .catch(err => { res.sendStatus(404);