fix potential crash, don't throw
This commit is contained in:
5
index.js
5
index.js
@@ -32,9 +32,11 @@ function removeKey (key) {
|
|||||||
if (info) {
|
if (info) {
|
||||||
clearTimeout(app.context.keys.get(key).timer)
|
clearTimeout(app.context.keys.get(key).timer)
|
||||||
if (info.file) {
|
if (info.file) {
|
||||||
|
console.log('Deleting file', info.file.path)
|
||||||
fs.unlink(info.file.path, (err) => {
|
fs.unlink(info.file.path, (err) => {
|
||||||
if (err) console.error(err)
|
if (err) console.error(err)
|
||||||
})
|
})
|
||||||
|
info.file = null
|
||||||
}
|
}
|
||||||
app.context.keys.delete(key)
|
app.context.keys.delete(key)
|
||||||
} else {
|
} else {
|
||||||
@@ -132,7 +134,8 @@ router.get('/download/:key', async ctx => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (info.agent !== ctx.get('user-agent')) {
|
if (info.agent !== ctx.get('user-agent')) {
|
||||||
throw new Error("User Agent doesnt match: " + info.agent + " VS " + ctx.get('user-agent'))
|
console.error("User Agent doesnt match: " + info.agent + " VS " + ctx.get('user-agent'))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
expireKey(key)
|
expireKey(key)
|
||||||
console.log('Sending file!')
|
console.log('Sending file!')
|
||||||
|
|||||||
Reference in New Issue
Block a user