expired ids should reject instead of returning null
This commit is contained in:
parent
0761fcf902
commit
15ac0e1d49
@ -117,7 +117,7 @@ app.get('/download/:id', (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
storage.filename(id).then(filename => {
|
storage.filename(id).then(filename => {
|
||||||
storage
|
return storage
|
||||||
.length(id)
|
.length(id)
|
||||||
.then(contentLength => {
|
.then(contentLength => {
|
||||||
storage.ttl(id).then(timeToExpiry => {
|
storage.ttl(id).then(timeToExpiry => {
|
||||||
@ -128,11 +128,11 @@ app.get('/download/:id', (req, res) => {
|
|||||||
timeToExpiry: timeToExpiry
|
timeToExpiry: timeToExpiry
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
res.status(404).render('notfound');
|
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
.catch(() => {
|
||||||
|
res.status(404).render('notfound');
|
||||||
|
});;
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/assets/download/:id', (req, res) => {
|
app.get('/assets/download/:id', (req, res) => {
|
||||||
|
@ -90,11 +90,10 @@ function ttl(id) {
|
|||||||
function filename(id) {
|
function filename(id) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
redis_client.hget(id, 'filename', (err, reply) => {
|
redis_client.hget(id, 'filename', (err, reply) => {
|
||||||
if (!err) {
|
if (err || !reply) {
|
||||||
resolve(reply);
|
return reject();
|
||||||
} else {
|
|
||||||
reject(err);
|
|
||||||
}
|
}
|
||||||
|
resolve(reply);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user