Просмотр исходного кода

check if files exist before fingerprinting them issue #75 on sharelatex

Henry Oswald 12 лет назад
Родитель
Сommit
4864eeba0a
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      services/web/app/coffee/infrastructure/ExpressLocals.coffee

+ 9 - 4
services/web/app/coffee/infrastructure/ExpressLocals.coffee

@@ -25,10 +25,15 @@ for path in [
     "/brand/plans.css"
     "/brand/plans.css"
 ]
 ]
 	filePath = Path.join __dirname, "../../../", "public#{path}"
 	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)->
 module.exports = (app)->
 	app.use (req, res, next)->
 	app.use (req, res, next)->