fingerprints are grouped into lists with this change

fingerprints are shared when require.js pulls in other resources.
this change means changes to either ace.js or mode-latex.js will
result in different fingerprints for those files.
This commit is contained in:
Henry Oswald 2016-09-27 16:21:04 +01:00
parent b497182557
commit a00cb707cc

View file

@ -7,6 +7,7 @@ querystring = require('querystring')
SystemMessageManager = require("../Features/SystemMessages/SystemMessageManager")
AuthenticationController = require("../Features/Authentication/AuthenticationController")
_ = require("underscore")
async = require("async")
Modules = require "./Modules"
Url = require "url"
@ -21,29 +22,46 @@ jsPath =
"/js/"
logger.log "Generating file fingerprints..."
for path in [
"#{jsPath}libs/require.js",
"#{jsPath}ide.js",
"#{jsPath}main.js",
"#{jsPath}libs.js",
"#{jsPath}ace/ace.js",
"#{jsPath}libs/pdfjs-1.3.91p1/pdf.js",
"#{jsPath}libs/pdfjs-1.3.91p1/pdf.worker.js",
"#{jsPath}libs/pdfjs-1.3.91p1/compatibility.js",
"/stylesheets/style.css"
]
filePath = Path.join __dirname, "../../../", "public#{path}"
getFileContent = (filePath)->
filePath = Path.join __dirname, "../../../", "public#{filePath}"
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
return content
else
logger.log filePath:filePath, "file does not exist for fingerprints"
return ""
logger.log "Generating file fingerprints..."
pathList = [
["#{jsPath}libs/require.js"]
["#{jsPath}ide.js"]
["#{jsPath}main.js"]
["#{jsPath}libs.js"]
["#{jsPath}ace/ace.js","#{jsPath}ace/mode-latex.js", "#{jsPath}ace/snippets/latex.js"]
["#{jsPath}libs/pdfjs-1.3.91p1/pdf.js"]
["#{jsPath}libs/pdfjs-1.3.91p1/pdf.worker.js"]
["#{jsPath}libs/pdfjs-1.3.91p1/compatibility.js"]
["/stylesheets/style.css"]
]
for paths in pathList
contentList = _.map(paths, getFileContent)
content = contentList.join("")
hash = crypto.createHash("md5").update(content).digest("hex")
_.each paths, (filePath)->
logger.log "#{filePath}: #{hash}"
fingerprints[filePath] = hash
getFingerprint = (path) ->
console.log path, fingerprints[path], "!!!!!!!!!!!"
if fingerprints[path]?
return fingerprints[path]
else