Parcourir la source

rename saveProjectStateHash to saveProjectState

Brian Gough il y a 9 ans
Parent
commit
0a242bac3c

+ 2 - 2
services/clsi/app/coffee/ResourceStateManager.coffee

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

+ 2 - 2
services/clsi/app/coffee/ResourceWriter.coffee

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

+ 7 - 7
services/clsi/test/unit/coffee/ResourceWriterTests.coffee

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