Преглед изворни кода

rename EditorController.replaceFile -> replaceFileWithoutLock

Hayden Faulds пре 8 година
родитељ
комит
76c7dff33a

+ 1 - 1
services/web/app/coffee/Features/Editor/EditorController.coffee

@@ -59,7 +59,7 @@ module.exports = EditorController =
 			EditorRealTimeController.emitToRoom(project_id, 'reciveNewFile', folder_id, fileRef, source)
 			EditorRealTimeController.emitToRoom(project_id, 'reciveNewFile', folder_id, fileRef, source)
 			callback(err, fileRef)
 			callback(err, fileRef)
 
 
-	replaceFile: (project_id, file_id, fsPath, source, user_id, callback = (error) ->)->
+	replaceFileWithoutLock: (project_id, file_id, fsPath, source, user_id, callback = (error) ->)->
 		ProjectEntityHandler.replaceFile project_id, file_id, fsPath, user_id, callback
 		ProjectEntityHandler.replaceFile project_id, file_id, fsPath, user_id, callback
 
 
 	addFolder : (project_id, folder_id, folderName, source, callback = (error, folder)->)->
 	addFolder : (project_id, folder_id, folderName, source, callback = (error, folder)->)->

+ 1 - 1
services/web/app/coffee/Features/ThirdPartyDataStore/UpdateMerger.coffee

@@ -69,7 +69,7 @@ module.exports =
 					logger.err err:err, project_id:project_id, file_id:file_id, path:path, "error processing file"
 					logger.err err:err, project_id:project_id, file_id:file_id, path:path, "error processing file"
 					return callback(err)
 					return callback(err)
 				else if file_id?
 				else if file_id?
-					editorController.replaceFile project_id, file_id, fsPath, source, user_id, finish
+					editorController.replaceFileWithoutLock project_id, file_id, fsPath, source, user_id, finish
 				else
 				else
 					editorController.addFile project_id, folder?._id, fileName, fsPath, source, user_id, finish
 					editorController.addFile project_id, folder?._id, fileName, fsPath, source, user_id, finish
 
 

+ 1 - 1
services/web/app/coffee/Features/Uploads/FileSystemImportManager.coffee

@@ -50,7 +50,7 @@ module.exports = FileSystemImportManager =
 							existingFile = fileRef
 							existingFile = fileRef
 							break
 							break
 					if existingFile?
 					if existingFile?
-						EditorController.replaceFile project_id, existingFile._id, path, "upload", user_id, callback
+						EditorController.replaceFileWithoutLock project_id, existingFile._id, path, "upload", user_id, callback
 					else
 					else
 						EditorController.addFileWithoutLock project_id, folder_id, name, path, "upload", user_id, callback
 						EditorController.addFileWithoutLock project_id, folder_id, name, path, "upload", user_id, callback
 
 

+ 5 - 6
services/web/test/unit/coffee/Editor/EditorControllerTests.coffee

@@ -243,10 +243,7 @@ describe "EditorController", ->
 				error.should.equal "timed out"
 				error.should.equal "timed out"
 				done()			
 				done()			
 
 
-
-
-
-	describe "replaceFile", ->
+	describe "replaceFileWithoutLock", ->
 		beforeEach ->
 		beforeEach ->
 			@project_id = "12dsankj"
 			@project_id = "12dsankj"
 			@file_id = "file_id_here"
 			@file_id = "file_id_here"
@@ -254,8 +251,10 @@ describe "EditorController", ->
 
 
 		it 'should send the replace file message to the editor controller', (done)->
 		it 'should send the replace file message to the editor controller', (done)->
 			@ProjectEntityHandler.replaceFile = sinon.stub().callsArgWith(4)
 			@ProjectEntityHandler.replaceFile = sinon.stub().callsArgWith(4)
-			@EditorController.replaceFile @project_id, @file_id, @fsPath, @source, @user_id, =>
-				@ProjectEntityHandler.replaceFile.calledWith(@project_id, @file_id, @fsPath, @user_id).should.equal true
+			@EditorController.replaceFileWithoutLock @project_id, @file_id, @fsPath, @source, @user_id, =>
+				@ProjectEntityHandler.replaceFile
+					.calledWith(@project_id, @file_id, @fsPath, @user_id)
+					.should.equal true
 				done()
 				done()
 
 
 	describe 'addFolderWithoutLock :', ->
 	describe 'addFolderWithoutLock :', ->

+ 3 - 3
services/web/test/unit/coffee/ThirdPartyDataStore/UpdateMergerTests.coffee

@@ -115,7 +115,7 @@ describe 'UpdateMerger :', ->
 			@fileName = "file.png"
 			@fileName = "file.png"
 			@fsPath = "fs/path.tex"
 			@fsPath = "fs/path.tex"
 			@editorController.addFile = sinon.stub().callsArg(6)
 			@editorController.addFile = sinon.stub().callsArg(6)
-			@editorController.replaceFile = sinon.stub().callsArg(5)
+			@editorController.replaceFileWithoutLock = sinon.stub().callsArg(5)
 			@editorController.deleteEntity = sinon.stub()
 			@editorController.deleteEntity = sinon.stub()
 			@editorController.mkdirp = sinon.stub().withArgs(@project_id).callsArgWith(2, null, [@folder], @folder)
 			@editorController.mkdirp = sinon.stub().withArgs(@project_id).callsArgWith(2, null, [@folder], @folder)
 			@updateMerger.p.writeStreamToDisk = sinon.stub().withArgs(@project_id, @file_id, @update).callsArgWith(3, null, @fsPath)
 			@updateMerger.p.writeStreamToDisk = sinon.stub().withArgs(@project_id, @file_id, @update).callsArgWith(3, null, @fsPath)
@@ -123,14 +123,14 @@ describe 'UpdateMerger :', ->
 		it 'should replace file if the file already exists', (done)->
 		it 'should replace file if the file already exists', (done)->
 			@updateMerger.p.processFile @project_id, @file_id, @fsPath, @path, @source, @user_id, =>
 			@updateMerger.p.processFile @project_id, @file_id, @fsPath, @path, @source, @user_id, =>
 				@editorController.addFile.called.should.equal false
 				@editorController.addFile.called.should.equal false
-				@editorController.replaceFile.calledWith(@project_id, @file_id, @fsPath, @source, @user_id).should.equal true
+				@editorController.replaceFileWithoutLock.calledWith(@project_id, @file_id, @fsPath, @source, @user_id).should.equal true
 				done()
 				done()
 
 
 		it 'should call add file if the file does not exist', (done)->
 		it 'should call add file if the file does not exist', (done)->
 			@updateMerger.p.processFile @project_id, undefined, @fsPath, @path, @source, @user_id, =>
 			@updateMerger.p.processFile @project_id, undefined, @fsPath, @path, @source, @user_id, =>
 				@editorController.mkdirp.calledWith(@project_id, "folder/").should.equal true
 				@editorController.mkdirp.calledWith(@project_id, "folder/").should.equal true
 				@editorController.addFile.calledWith(@project_id, @folder_id, @fileName, @fsPath, @source, @user_id).should.equal true
 				@editorController.addFile.calledWith(@project_id, @folder_id, @fileName, @fsPath, @source, @user_id).should.equal true
-				@editorController.replaceFile.called.should.equal false
+				@editorController.replaceFileWithoutLock.called.should.equal false
 				done()
 				done()
 
 
 	describe 'delete entity :', (done)->
 	describe 'delete entity :', (done)->

+ 5 - 4
services/web/test/unit/coffee/Uploads/FileSystemImportManagerTests.coffee

@@ -126,12 +126,12 @@ describe "FileSystemImportManager", ->
 		beforeEach ->
 		beforeEach ->
 			@EditorController.addFileWithoutLock = sinon.stub()
 			@EditorController.addFileWithoutLock = sinon.stub()
 			@FileSystemImportManager._isSafeOnFileSystem = sinon.stub().callsArgWith(1, null, false)
 			@FileSystemImportManager._isSafeOnFileSystem = sinon.stub().callsArgWith(1, null, false)
-			@EditorController.replaceFile = sinon.stub()
+			@EditorController.replaceFileWithoutLock = sinon.stub()
 			@FileSystemImportManager.addFile @user_id, @project_id, @folder_id, @name, @path_on_disk, false, @callback
 			@FileSystemImportManager.addFile @user_id, @project_id, @folder_id, @name, @path_on_disk, false, @callback
 
 
 		it "should node add the file", ->
 		it "should node add the file", ->
 			@EditorController.addFileWithoutLock.called.should.equal false
 			@EditorController.addFileWithoutLock.called.should.equal false
-			@EditorController.replaceFile.called.should.equal false
+			@EditorController.replaceFileWithoutLock.called.should.equal false
 
 
 	describe "addFile with replace set to true", ->
 	describe "addFile with replace set to true", ->
 		describe "when the file doesn't exist", ->
 		describe "when the file doesn't exist", ->
@@ -169,7 +169,7 @@ describe "FileSystemImportManager", ->
 				}
 				}
 				@FileSystemImportManager._isSafeOnFileSystem = sinon.stub().callsArgWith(1, null, true)
 				@FileSystemImportManager._isSafeOnFileSystem = sinon.stub().callsArgWith(1, null, true)
 				@ProjectLocator.findElement = sinon.stub().callsArgWith(1, null, @folder)
 				@ProjectLocator.findElement = sinon.stub().callsArgWith(1, null, @folder)
-				@EditorController.replaceFile = sinon.stub().callsArg(5)
+				@EditorController.replaceFileWithoutLock = sinon.stub().callsArg(5)
 				@FileSystemImportManager.addFile @user_id, @project_id, @folder_id, @name, @path_on_disk, true, @callback
 				@FileSystemImportManager.addFile @user_id, @project_id, @folder_id, @name, @path_on_disk, true, @callback
 
 
 			it "should look up the folder", ->
 			it "should look up the folder", ->
@@ -178,7 +178,8 @@ describe "FileSystemImportManager", ->
 					.should.equal true
 					.should.equal true
 
 
 			it "should replace the file", ->
 			it "should replace the file", ->
-				@EditorController.replaceFile.calledWith(@project_id, @file_id, @path_on_disk, "upload", @user_id)
+				@EditorController.replaceFileWithoutLock
+					.calledWith(@project_id, @file_id, @path_on_disk, "upload", @user_id)
 					.should.equal true
 					.should.equal true
 
 
 	describe "addFolder", ->
 	describe "addFolder", ->