rename saveProjectStateHash to saveProjectState

This commit is contained in:
Brian Gough 2017-09-08 13:56:40 +01:00
parent 66431fc2b8
commit 0a242bac3c
3 changed files with 11 additions and 11 deletions

View file

@ -23,7 +23,7 @@ module.exports = ResourceStateManager =
SYNC_STATE_FILE: ".project-sync-state"
saveProjectStateHash: (state, resources, basePath, callback = (error) ->) ->
saveProjectState: (state, resources, basePath, callback = (error) ->) ->
stateFile = Path.join(basePath, @SYNC_STATE_FILE)
if not state? # remove the file if no state passed in
logger.log state:state, basePath:basePath, "clearing sync state"
@ -37,7 +37,7 @@ module.exports = ResourceStateManager =
resourceList = (resource.path for resource in resources)
fs.writeFile stateFile, [resourceList..., "stateHash:#{state}"].join("\n"), callback
checkProjectStateHashMatches: (state, basePath, callback = (error, resources) ->) ->
checkProjectStateMatches: (state, basePath, callback = (error, resources) ->) ->
stateFile = Path.join(basePath, @SYNC_STATE_FILE)
SafeReader.readFile stateFile, 128*1024, 'utf8', (err, result) ->
return callback(err) if err?

View file

@ -16,7 +16,7 @@ module.exports = ResourceWriter =
syncResourcesToDisk: (request, basePath, callback = (error, resourceList) ->) ->
if request.syncType is "incremental"
logger.log project_id: request.project_id, user_id: request.user_id, "incremental sync"
ResourceStateManager.checkProjectStateHashMatches request.syncState, basePath, (error, resourceList) ->
ResourceStateManager.checkProjectStateMatches request.syncState, basePath, (error, resourceList) ->
return callback(error) if error?
ResourceWriter._removeExtraneousFiles resourceList, basePath, (error, outputFiles, allFiles) ->
return callback(error) if error?
@ -29,7 +29,7 @@ module.exports = ResourceWriter =
logger.log project_id: request.project_id, user_id: request.user_id, "full sync"
@saveAllResourcesToDisk request.project_id, request.resources, basePath, (error) ->
return callback(error) if error?
ResourceStateManager.saveProjectStateHash request.syncState, request.resources, basePath, (error) ->
ResourceStateManager.saveProjectState request.syncState, request.resources, basePath, (error) ->
return callback(error) if error?
callback(null, request.resources)

View file

@ -32,7 +32,7 @@ describe "ResourceWriter", ->
]
@ResourceWriter._writeResourceToDisk = sinon.stub().callsArg(3)
@ResourceWriter._removeExtraneousFiles = sinon.stub().callsArg(2)
@ResourceStateManager.saveProjectStateHash = sinon.stub().callsArg(3)
@ResourceStateManager.saveProjectState = sinon.stub().callsArg(3)
@ResourceWriter.syncResourcesToDisk({
project_id: @project_id
syncState: @syncState = "0123456789abcdef"
@ -51,7 +51,7 @@ describe "ResourceWriter", ->
.should.equal true
it "should store the sync state and resource list", ->
@ResourceStateManager.saveProjectStateHash
@ResourceStateManager.saveProjectState
.calledWith(@syncState, @resources, @basePath)
.should.equal true
@ -65,8 +65,8 @@ describe "ResourceWriter", ->
]
@ResourceWriter._writeResourceToDisk = sinon.stub().callsArg(3)
@ResourceWriter._removeExtraneousFiles = sinon.stub().callsArgWith(2, null, @outputFiles = [], @allFiles = [])
@ResourceStateManager.checkProjectStateHashMatches = sinon.stub().callsArgWith(2, null, @resources)
@ResourceStateManager.saveProjectStateHash = sinon.stub().callsArg(3)
@ResourceStateManager.checkProjectStateMatches = sinon.stub().callsArgWith(2, null, @resources)
@ResourceStateManager.saveProjectState = sinon.stub().callsArg(3)
@ResourceStateManager.checkResourceFiles = sinon.stub().callsArg(3)
@ResourceWriter.syncResourcesToDisk({
project_id: @project_id,
@ -76,7 +76,7 @@ describe "ResourceWriter", ->
}, @basePath, @callback)
it "should check the sync state matches", ->
@ResourceStateManager.checkProjectStateHashMatches
@ResourceStateManager.checkProjectStateMatches
.calledWith(@syncState, @basePath)
.should.equal true
@ -104,7 +104,7 @@ describe "ResourceWriter", ->
@resources = [
"resource-1-mock"
]
@ResourceStateManager.checkProjectStateHashMatches = sinon.stub().callsArgWith(2, @error = new Error())
@ResourceStateManager.checkProjectStateMatches = sinon.stub().callsArgWith(2, @error = new Error())
@ResourceWriter.syncResourcesToDisk({
project_id: @project_id,
syncType: "incremental",
@ -113,7 +113,7 @@ describe "ResourceWriter", ->
}, @basePath, @callback)
it "should check whether the sync state matches", ->
@ResourceStateManager.checkProjectStateHashMatches
@ResourceStateManager.checkProjectStateMatches
.calledWith(@syncState, @basePath)
.should.equal true