Explorar el Código

fixed bug where file uploader was calling cb on read stream not write stream, race condition created.

Henry Oswald hace 12 años
padre
commit
65f849aad0

+ 1 - 1
services/web/app/coffee/Features/FileStore/FileStoreHandler.coffee

@@ -13,7 +13,7 @@ module.exports =
 			uri: @_buildUrl(project_id, file_id)
 		writeStream = request(opts)
 		readStream.pipe writeStream
-		readStream.on "end", callback
+		writeStream.on "end", callback
 		readStream.on "error", (err)->
 			logger.err err:err, project_id:project_id, file_id:file_id, fsPath:fsPath, "something went wrong on the read stream of uploadFileFromDisk"
 			callback err

+ 5 - 1
services/web/test/UnitTests/coffee/FileStore/FileStoreHandlerTests.coffee

@@ -10,7 +10,11 @@ describe "FileStoreHandler", ->
 	beforeEach ->
 		@fs =
 			createReadStream : sinon.stub()
-		@writeStream = {my:"writeStream", on:->}
+		@writeStream =
+			my:"writeStream"
+			on: (type, cb)-> 
+				if type == "end"
+					cb()
 		@readStream = {my:"readStream"}
 		@request = sinon.stub()
 		@settings = apis:{filestore:{url:"http//filestore.sharelatex.test"}}