mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-05 02:36:52 +00:00
Merge pull request #37 from sharelatex/bg-reduce-logging-of-not-found-errors
reduce logging of not found errors
This commit is contained in:
commit
8951f297aa
3 changed files with 6 additions and 3 deletions
|
@ -29,10 +29,10 @@ module.exports = FileController =
|
|||
logger.log start: range.start, end: range.end, "getting range of bytes from file"
|
||||
FileHandler.getFile bucket, key, options, (err, fileStream)->
|
||||
if err?
|
||||
logger.err err:err, key:key, bucket:bucket, format:format, style:style, "problem getting file"
|
||||
if err instanceof Errors.NotFoundError
|
||||
return res.send 404
|
||||
else
|
||||
logger.err err:err, key:key, bucket:bucket, format:format, style:style, "problem getting file"
|
||||
return res.send 500
|
||||
else if req.query.cacheWarm
|
||||
logger.log key:key, bucket:bucket, format:format, style:style, "request is only for cache warm so not sending stream"
|
||||
|
|
|
@ -6,6 +6,7 @@ FileConverter = require("./FileConverter")
|
|||
KeyBuilder = require("./KeyBuilder")
|
||||
async = require("async")
|
||||
ImageOptimiser = require("./ImageOptimiser")
|
||||
Errors = require('./Errors')
|
||||
|
||||
module.exports = FileHandler =
|
||||
|
||||
|
@ -32,7 +33,7 @@ module.exports = FileHandler =
|
|||
|
||||
_getStandardFile: (bucket, key, opts, callback)->
|
||||
PersistorManager.getFileStream bucket, key, opts, (err, fileStream)->
|
||||
if err?
|
||||
if err? and !(err instanceof Errors.NotFoundError)
|
||||
logger.err bucket:bucket, key:key, opts:FileHandler._scrubSecrets(opts), "error getting fileStream"
|
||||
callback err, fileStream
|
||||
|
||||
|
|
|
@ -76,7 +76,9 @@ module.exports =
|
|||
s3Stream = s3Client.get(key, headers)
|
||||
s3Stream.end()
|
||||
s3Stream.on 'response', (res) ->
|
||||
if res.statusCode == 404
|
||||
if res.statusCode in [403, 404]
|
||||
# S3 returns a 403 instead of a 404 when the user doesn't have
|
||||
# permission to list the bucket contents.
|
||||
logger.log bucketName:bucketName, key:key, "file not found in s3"
|
||||
return callback new Errors.NotFoundError("File not found in S3: #{bucketName}:#{key}"), null
|
||||
if res.statusCode not in [200, 206]
|
||||
|
|
Loading…
Reference in a new issue