use 'response' to send 'NoSuchKey' when local file is not found

This commit is contained in:
Brian Gough 2014-12-22 11:10:05 +00:00
parent 8744cf94a5
commit 7d96f3aadd
2 changed files with 8 additions and 2 deletions

View file

@ -2,6 +2,7 @@ logger = require("logger-sharelatex")
fs = require("fs")
LocalFileWriter = require("./LocalFileWriter")
rimraf = require("rimraf")
response = require ("response")
filterName = (key) ->
return key.replace /\//g, "_"
@ -32,8 +33,12 @@ module.exports =
sourceStream = fs.createReadStream "#{location}/#{filteredName}"
sourceStream.on 'error', (err) ->
logger.err err:err, location:location, name:name, "Error reading from file"
callback err
callback null,sourceStream
if err.code = 'ENOENT'
callback null, response().html('NoSuchKey: file not found\n')
else
callback err
sourceStream.on 'readable', () ->
callback null, sourceStream
copyFile: (location, fromName, toName, callback = (err)->)->

View file

@ -21,6 +21,7 @@
"node-uuid": "~1.4.1",
"pngcrush": "0.0.3",
"request": "2.14.0",
"response": "0.14.0",
"rimraf": "2.2.8",
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#master",
"stream-buffers": "~0.2.5",