include the options in the project state hash

This commit is contained in:
Brian Gough
2017-09-01 16:36:51 +01:00
parent 7bb4638186
commit d9557fcbf5
4 changed files with 46 additions and 19 deletions
@@ -127,7 +127,7 @@ module.exports = ClsiManager =
if options.incrementalCompilesEnabled or options.syncType? # new way, either incremental or full
timer = new Metrics.Timer("editor.compile-getdocs-redis")
ClsiManager.getContentFromDocUpdaterIfMatch project_id, project, (error, projectStateHash, docUpdaterDocs) ->
ClsiManager.getContentFromDocUpdaterIfMatch project_id, project, options, (error, projectStateHash, docUpdaterDocs) ->
timer.done()
return callback(error) if error?
logger.log project_id: project_id, projectStateHash: projectStateHash, docs: docUpdaterDocs?, "checked project state"
@@ -150,8 +150,8 @@ module.exports = ClsiManager =
return callback(error) if error?
ClsiManager._finaliseRequest project_id, options, project, docs, files, callback
getContentFromDocUpdaterIfMatch: (project_id, project, callback = (error, projectStateHash, docs) ->) ->
ClsiStateManager.computeHash project, (error, projectStateHash) ->
getContentFromDocUpdaterIfMatch: (project_id, project, options, callback = (error, projectStateHash, docs) ->) ->
ClsiStateManager.computeHash project, options, (error, projectStateHash) ->
return callback(error) if error?
DocumentUpdaterHandler.getProjectDocsIfMatch project_id, projectStateHash, (error, docs) ->
return callback(error) if error?
@@ -22,10 +22,14 @@ buildState = (s) ->
module.exports = ClsiStateManager =
computeHash: (project, callback = (err, hash) ->) ->
computeHash: (project, options, callback = (err, hash) ->) ->
ProjectEntityHandler.getAllEntitiesFromProject project, (err, docs, files) ->
fileList = ("#{f.file._id}:#{f.file.rev}:#{f.file.created}:#{f.path}" for f in files or [])
docList = ("#{d.doc._id}:#{d.path}" for d in docs or [])
sortedEntityList = [docList..., fileList...].sort()
hash = buildState(sortedEntityList.join("\n"))
# ignore the isAutoCompile options as it doesn't affect the
# output, but include all other options e.g. draft
optionsList = ("option #{key}:#{value}" for key, value of options or {} when not (key in ['isAutoCompile']))
sortedOptionsList = optionsList.sort()
hash = buildState([sortedEntityList..., sortedOptionsList...].join("\n"))
callback(null, hash)