Merge pull request #2760 from overleaf/em-faster-uploads

Make a single Mongo update when uploading projects

GitOrigin-RevId: de102d3e112c9014ca5885f963e35971e4db6cee
This commit is contained in:
Eric Mc Sween
2020-04-23 07:51:06 -04:00
committed by Copybot
parent 674afe400d
commit 27941dc8af
12 changed files with 804 additions and 581 deletions

View File

@@ -1045,7 +1045,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
this.FolderStructureBuilder.buildFolderStructure
.withArgs(this.docUploads, this.fileUploads)
.returns(this.mockRootFolder)
this.updateExpectation = this.ProjectMock.expects('updateOne')
this.updateExpectation = this.ProjectMock.expects('findOneAndUpdate')
.withArgs(
{
_id: this.project._id,
@@ -1053,14 +1053,15 @@ describe('ProjectEntityMongoUpdateHandler', function() {
'rootFolder.0.docs.0': { $exists: false },
'rootFolder.0.files.0': { $exists: false }
},
{ $set: { rootFolder: [this.mockRootFolder] }, $inc: { version: 1 } }
{ $set: { rootFolder: [this.mockRootFolder] }, $inc: { version: 1 } },
{ new: true, lean: true, fields: { version: 1 } }
)
.chain('exec')
})
describe('happy path', function() {
beforeEach(async function() {
this.updateExpectation.resolves({ n: 1 })
this.updateExpectation.resolves({ version: 1 })
await this.subject.promises.createNewFolderStructure(
this.project._id,
this.docUploads,
@@ -1075,7 +1076,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
describe("when the update doesn't find a matching document", function() {
beforeEach(async function() {
this.updateExpectation.resolves({ n: 0 })
this.updateExpectation.resolves(null)
})
it('throws an error', async function() {