Просмотр исходного кода

Revert "Merge pull request #23 from sharelatex/bg-optimise-get-all-docs"

This reverts commit c1337cf23f37bd9ba48419accf1f54c00390e0ea, reversing
changes made to fbb2fa15bf4239db006db742f906554d61a0eac4.
Brian Gough 9 лет назад
Родитель
Сommit
abe90cad10

+ 10 - 24
services/docstore/app/coffee/DocManager.coffee

@@ -55,31 +55,17 @@ module.exports = DocManager =
 				return callback(err)
 			callback(err, doc)
 
-	_getAllDocs: (project_id, filter, callback = (error, docs) ->) ->
-		MongoManager.getProjectsDocs project_id, {include_deleted: false}, filter, (error, docs) ->
-			if err?
-				return callback(error)
-			else if !docs?
-				return callback new Errors.NotFoundError("No docs for project #{project_id}")
-			else
-				callback(null, docs)
-
 	getAllNonDeletedDocs: (project_id, filter, callback = (error, docs) ->) ->
-		# load docs optimistically, only unarchive if results are incomplete
-		DocManager._getAllDocs project_id, filter, (error, docs) ->
-			return callback(error) if error?
-			# check if any docs have been archived
-			docsInS3 = (doc for doc in docs when doc?.inS3)
-			if docsInS3.length > 0
-				DocArchive.unArchiveAllDocs project_id, (error) ->
-					if error?
-						logger.err err:error, project_id:project_id, "error unarchiving docs"
-						return callback(error)
-					# now reload the docs after unarchiving
-					DocManager._getAllDocs project_id, filter, callback
-			else
-				# return docs immediately, nothing in s3
-				return callback(null, docs)
+		DocArchive.unArchiveAllDocs project_id, (error) ->
+			if error?
+				return callback(error)
+			MongoManager.getProjectsDocs project_id, {include_deleted: false}, filter, (error, docs) ->
+				if err?
+					return callback(error)
+				else if !docs?
+					return callback new Errors.NotFoundError("No docs for project #{project_id}")
+				else
+					return callback(null, docs)
 
 	updateDoc: (project_id, doc_id, lines, version, ranges, callback = (error, modified, rev) ->) ->
 		if !lines? or !version? or !ranges?

+ 0 - 23
services/docstore/test/unit/coffee/DocManagerTests.coffee

@@ -215,29 +215,6 @@ describe "DocManager", ->
 					.calledWith(new Errors.NotFoundError("No docs for project #{@project_id}"))
 					.should.equal true
 
-		describe "when there are some archived docs for the project", ->
-			beforeEach ->
-				@stubs = [{ _id: @doc_id, project_id: @project_id, inS3:true }]
-				@docs = [{ _id: @doc_id, project_id: @project_id, lines: ["mock-lines"] }]
-				@MongoManager.getProjectsDocs = sinon.stub()
-					.callsArgWith(3, null, @stubs) # first call
-					.callsArgWith(3, null, @docs)  # second call (after unarchiving)
-				@DocArchiveManager.unArchiveAllDocs = sinon.stub().callsArgWith(1, null)
-				@DocManager.getAllNonDeletedDocs @project_id, @filter, @callback
-
-			it "should get the project from the database", ->
-				@MongoManager.getProjectsDocs
-					.calledWith(@project_id, {include_deleted: false}, @filter)
-					.should.equal true
-
-			it "should unarchive the documents", ->
-				@DocArchiveManager.unArchiveAllDocs
-					.calledWith(@project_id)
-					.should.equal true
-
-			it "should return the docs", ->
-				@callback.calledWith(null, @docs).should.equal true
-
 	describe "deleteDoc", ->
 		describe "when the doc exists", ->
 			beforeEach ->