From 4864eeba0aa6a15a80c5f4b931c08036cf49fe7a Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Thu, 13 Mar 2014 12:38:16 +0000 Subject: [PATCH] check if files exist before fingerprinting them issue #75 on sharelatex --- .../app/coffee/infrastructure/ExpressLocals.coffee | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/services/web/app/coffee/infrastructure/ExpressLocals.coffee b/services/web/app/coffee/infrastructure/ExpressLocals.coffee index 4ae194d674..053a6f0dac 100644 --- a/services/web/app/coffee/infrastructure/ExpressLocals.coffee +++ b/services/web/app/coffee/infrastructure/ExpressLocals.coffee @@ -25,10 +25,15 @@ for path in [ "/brand/plans.css" ] filePath = Path.join __dirname, "../../../", "public#{path}" - content = fs.readFileSync filePath - hash = crypto.createHash("md5").update(content).digest("hex") - logger.log "#{filePath}: #{hash}" - fingerprints[path] = hash + exists = fs.existsSync filePath + if exists + content = fs.readFileSync filePath + hash = crypto.createHash("md5").update(content).digest("hex") + logger.log "#{filePath}: #{hash}" + fingerprints[path] = hash + else + logger.log filePath:filePath, "file does not exist for fingerprints" + module.exports = (app)-> app.use (req, res, next)->