Fix using respond to serve blob errors
This commit is contained in:
@@ -162,9 +162,11 @@ exports.init = function (sbot, config) {
|
|||||||
function serveBlob(req, res, sbot, id) {
|
function serveBlob(req, res, sbot, id) {
|
||||||
if (req.headers['if-none-match'] === id) return respond(res, 304)
|
if (req.headers['if-none-match'] === id) return respond(res, 304)
|
||||||
sbot.blobs.has(id, function (err, has) {
|
sbot.blobs.has(id, function (err, has) {
|
||||||
if (err && /^invalid/.test(err.message)) return respond(400, err.message)
|
if (err) {
|
||||||
if (err) return respond(500, err.message || err)
|
if (/^invalid/.test(err.message)) return respond(res, 400, err.message)
|
||||||
if (!has) return respond(404, 'Not found')
|
else return respond(res, 500, err.message || err)
|
||||||
|
}
|
||||||
|
if (!has) return respond(res, 404, 'Not found')
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
'Cache-Control': 'public, max-age=315360000',
|
'Cache-Control': 'public, max-age=315360000',
|
||||||
'etag': id
|
'etag': id
|
||||||
|
|||||||
Reference in New Issue
Block a user