Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Changed naming for some pages, no longer stores files by name on server #25

Merged
merged 6 commits into from May 31, 2017

Conversation

abhinadduri
Copy link
Collaborator

No description provided.

app.js Outdated

res.download(__dirname + '/static/' + reply);
client.del(id);
res.download(__dirname + '/static/' + id, reply);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move the client.del(id) into the callback of download. We'll get an error there if something went wrong, and at that point we can also delete the file off the disk.

Something like:

res.download(__dirname + '/static/' + id, reply, function (err) {
  if (!err) {
    client.del(id)
    fs.unlinkSync(__dirname + '/static/' + id)
  }
  // log the error
})

app.js Outdated
@@ -26,12 +26,12 @@ app.get('/assets/download/:id', function(req, res) {
let id = req.params.id;
client.hget(id, "filename", function(err, reply) { // maybe some expiration logic too
if (!reply) {
res.send('error');
res.send('This link has expired!');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should return a 404 in this case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants