From 4d4cf4f6933720f6aaef035738670a27e5fac6cf Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 2 Aug 2017 16:25:47 +0100 Subject: [PATCH] project state can be stored per project there is no need to store it per project+user because it reflects the state of the project itself --- .../Features/Compile/ClsiManager.coffee | 8 ++++---- .../Features/Compile/ClsiStateManager.coffee | 20 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/services/web/app/coffee/Features/Compile/ClsiManager.coffee b/services/web/app/coffee/Features/Compile/ClsiManager.coffee index 6f9b765554..2adbbf2e53 100755 --- a/services/web/app/coffee/Features/Compile/ClsiManager.coffee +++ b/services/web/app/coffee/Features/Compile/ClsiManager.coffee @@ -25,7 +25,7 @@ module.exports = ClsiManager = callback(error, status, result...) sendRequestOnce: (project_id, user_id, options = {}, callback = (error, status, outputFiles, clsiServerId, validationProblems) ->) -> - ClsiManager._buildRequest project_id, user_id, options, (error, req) -> + ClsiManager._buildRequest project_id, options, (error, req) -> return callback(error) if error? logger.log project_id: project_id, "sending compile to CLSI" console.log "REQUEST", JSON.stringify(req, null, 2) @@ -119,7 +119,7 @@ module.exports = ClsiManager = VALID_COMPILERS: ["pdflatex", "latex", "xelatex", "lualatex"] - _buildRequest: (project_id, user_id, options={}, callback = (error, request) ->) -> + _buildRequest: (project_id, options={}, callback = (error, request) ->) -> Project.findById project_id, {}, (error, project) -> return callback(error) if error? return callback(new Errors.NotFoundError("project does not exist: #{project_id}")) if !project? @@ -127,7 +127,7 @@ module.exports = ClsiManager = if project.compiler not in ClsiManager.VALID_COMPILERS project.compiler = "pdflatex" - ClsiStateManager.checkState project_id, user_id, project, (error, stateOk, state) -> + ClsiStateManager.checkState project_id, project, (error, stateOk, state) -> return callback(error) if error? logger.log project_id: project_id, checkState: stateOk, "checked project state" console.log "OPTIONS ARE", options @@ -151,7 +151,7 @@ module.exports = ClsiManager = return callback(error) if error? console.log "DOCS", docs # FIXME want to store state after project has been sent to clsi - ClsiStateManager.setState project_id, user_id, project, (error, state) -> + ClsiStateManager.setState project_id, project, (error, state) -> if error? logger.err err:error, project_id:project_id, "error storing state in redis" #return callback(error) diff --git a/services/web/app/coffee/Features/Compile/ClsiStateManager.coffee b/services/web/app/coffee/Features/Compile/ClsiStateManager.coffee index f090ec6fc2..9f4c558eb6 100644 --- a/services/web/app/coffee/Features/Compile/ClsiStateManager.coffee +++ b/services/web/app/coffee/Features/Compile/ClsiStateManager.coffee @@ -4,8 +4,8 @@ rclient = RedisWrapper.client("clsi_state") logger = require "logger-sharelatex" crypto = require "crypto" -buildKey = (project_id, user_id)-> - return "clsistate:#{project_id}-#{user_id}" # FIXME: should we cluster these on project?? +buildKey = (project_id)-> + return "clsistate:#{project_id}" # FIXME: should we cluster these on project?? buildState = (project) -> JSON.stringify project @@ -16,9 +16,9 @@ OneHour = 3600 * 1000 module.exports = ClsiStateManager = - checkState: (project_id, user_id, project, callback = (err, ok) ->) -> + checkState: (project_id, project, callback = (err, ok) ->) -> newState = buildState(project) - @getState project_id, user_id, (err, oldState) -> + @getState project_id, (err, oldState) -> return callback(err) if err? if newState is oldState hash = crypto.createHash('sha1').update(newState, 'utf8').digest('hex') @@ -26,16 +26,16 @@ module.exports = ClsiStateManager = else callback(null,false) - getState: (project_id, user_id, callback = (err, state)->)-> - rclient.get buildKey(project_id, user_id), (err, state)-> + getState: (project_id, callback = (err, state)->)-> + rclient.get buildKey(project_id), (err, state)-> return callback(err) if err? - logger.log project_id: project_id, user_id: user_id, state: state, "got project state from redis" + logger.log project_id: project_id, state: state, "got project state from redis" return callback(null, state) - setState: (project_id, user_id, project, callback = (err)->)-> + setState: (project_id, project, callback = (err)->)-> projectState = buildState project - logger.log project_id: project_id, user_id: user_id, projectState: projectState, "setting project state in redis" - rclient.set buildKey(project_id, user_id), projectState, "PX", OneHour, (err) -> + logger.log project_id: project_id, projectState: projectState, "setting project state in redis" + rclient.set buildKey(project_id), projectState, "PX", OneHour, (err) -> return callback(err) if err? hash = crypto.createHash('sha1').update(projectState, 'utf8').digest('hex') callback(null,hash)