use syncType and syncState for clsi state options

This commit is contained in:
Brian Gough
2017-08-03 11:51:58 +01:00
parent 7e1d3d98e7
commit 74c26120b2
2 changed files with 14 additions and 14 deletions

View File

@@ -31,11 +31,11 @@ module.exports = RequestParser =
response.check = @_parseAttribute "check", response.check = @_parseAttribute "check",
compile.options.check, compile.options.check,
type: "string" type: "string"
response.incremental = @_parseAttribute "incremental", response.syncType = @_parseAttribute "syncType",
compile.options.incremental, compile.options.syncType,
type: "string" type: "string"
response.state = @_parseAttribute "state", response.syncState = @_parseAttribute "syncState",
compile.options.state, compile.options.syncState,
type: "string" type: "string"
if response.timeout > RequestParser.MAX_TIMEOUT if response.timeout > RequestParser.MAX_TIMEOUT

View File

@@ -13,23 +13,23 @@ parallelFileDownloads = settings.parallelFileDownloads or 1
module.exports = ResourceWriter = module.exports = ResourceWriter =
syncResourcesToDisk: (request, basePath, callback = (error) ->) -> syncResourcesToDisk: (request, basePath, callback = (error) ->) ->
if request.incremental? if request.syncType? is "incremental"
ResourceWriter.checkState request.incremental, basePath, (error, ok) -> ResourceWriter.checkSyncState request.syncState, basePath, (error, ok) ->
logger.log state: request.state, result:ok, "checked state on incremental request" logger.log syncState: request.syncState, result:ok, "checked state on incremental request"
return callback new Error("invalid state") if not ok return callback new Error("invalid state") if not ok
ResourceWriter.saveIncrementalResourcesToDisk request.project_id, request.resources, basePath, callback ResourceWriter.saveIncrementalResourcesToDisk request.project_id, request.resources, basePath, callback
else else
@saveAllResourcesToDisk request.project_id, request.resources, basePath, (error) -> @saveAllResourcesToDisk request.project_id, request.resources, basePath, (error) ->
return callback(error) if error? return callback(error) if error?
ResourceWriter.storeState request.state, basePath, callback ResourceWriter.storeSyncState request.syncState, basePath, callback
storeState: (state, basePath, callback) -> storeSyncState: (state, basePath, callback) ->
logger.log state:state, basePath:basePath, "writing state" logger.log state:state, basePath:basePath, "writing sync state"
fs.writeFile Path.join(basePath, ".resource-state"), state, {encoding: 'ascii'}, callback fs.writeFile Path.join(basePath, ".resource-sync-state"), state, {encoding: 'ascii'}, callback
checkState: (state, basePath, callback) -> checkSyncState: (state, basePath, callback) ->
fs.readFile Path.join(basePath, ".resource-state"), {encoding:'ascii'}, (err, oldState) -> fs.readFile Path.join(basePath, ".resource-sync-state"), {encoding:'ascii'}, (err, oldState) ->
logger.log state:state, oldState: oldState, basePath:basePath, err:err, "checking state" logger.log state:state, oldState: oldState, basePath:basePath, err:err, "checking sync state"
if state is oldState if state is oldState
return callback(null, true) return callback(null, true)
else else