mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 01:55:34 -05:00
Merge pull request #3655 from overleaf/jpa-change-write-path-doc-deletion
[ProjectEntityUpdateHandler] change write path for doc deletion GitOrigin-RevId: 7d7ece8fe25c1d59b3469c136d92c4c81e9f0f81
This commit is contained in:
parent
75dabdd299
commit
9692392bf8
4 changed files with 5 additions and 63 deletions
|
@ -70,7 +70,6 @@ module.exports = {
|
||||||
'changes'
|
'changes'
|
||||||
]),
|
]),
|
||||||
createNewFolderStructure: callbackify(wrapWithLock(createNewFolderStructure)),
|
createNewFolderStructure: callbackify(wrapWithLock(createNewFolderStructure)),
|
||||||
_insertDeletedDocReference: callbackify(_insertDeletedDocReference),
|
|
||||||
_insertDeletedFileReference: callbackify(_insertDeletedFileReference),
|
_insertDeletedFileReference: callbackify(_insertDeletedFileReference),
|
||||||
_putElement: callbackifyMultiResult(_putElement, ['result', 'project']),
|
_putElement: callbackifyMultiResult(_putElement, ['result', 'project']),
|
||||||
_confirmFolder,
|
_confirmFolder,
|
||||||
|
@ -86,7 +85,6 @@ module.exports = {
|
||||||
deleteEntity: wrapWithLock(deleteEntity),
|
deleteEntity: wrapWithLock(deleteEntity),
|
||||||
renameEntity: wrapWithLock(renameEntity),
|
renameEntity: wrapWithLock(renameEntity),
|
||||||
createNewFolderStructure: wrapWithLock(createNewFolderStructure),
|
createNewFolderStructure: wrapWithLock(createNewFolderStructure),
|
||||||
_insertDeletedDocReference,
|
|
||||||
_insertDeletedFileReference,
|
_insertDeletedFileReference,
|
||||||
_putElement
|
_putElement
|
||||||
}
|
}
|
||||||
|
@ -445,17 +443,6 @@ async function renameEntity(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function _insertDeletedDocReference(projectId, doc) {
|
|
||||||
await Project.updateOne(
|
|
||||||
{ _id: projectId },
|
|
||||||
{
|
|
||||||
$push: {
|
|
||||||
deletedDocs: { _id: doc._id, name: doc.name, deletedAt: new Date() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).exec()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function _insertDeletedFileReference(projectId, fileRef) {
|
async function _insertDeletedFileReference(projectId, fileRef) {
|
||||||
await DeletedFile.create({
|
await DeletedFile.create({
|
||||||
projectId,
|
projectId,
|
||||||
|
|
|
@ -1507,21 +1507,12 @@ const ProjectEntityUpdateHandler = {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
ProjectEntityMongoUpdateHandler._insertDeletedDocReference(
|
DocstoreManager.deleteDoc(projectId, docId, doc.name, error => {
|
||||||
project._id,
|
if (error) {
|
||||||
doc,
|
return callback(error)
|
||||||
error => {
|
|
||||||
if (error != null) {
|
|
||||||
return callback(error)
|
|
||||||
}
|
|
||||||
DocumentUpdaterHandler.deleteDoc(projectId, docId, error => {
|
|
||||||
if (error != null) {
|
|
||||||
return callback(error)
|
|
||||||
}
|
|
||||||
DocstoreManager.deleteDoc(projectId, docId, doc.name, callback)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
)
|
DocumentUpdaterHandler.deleteDoc(projectId, docId, callback)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -966,34 +966,6 @@ describe('ProjectEntityMongoUpdateHandler', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_insertDeletedDocReference', function() {
|
|
||||||
beforeEach(async function() {
|
|
||||||
this.ProjectMock.expects('updateOne')
|
|
||||||
.withArgs(
|
|
||||||
{ _id: this.project._id },
|
|
||||||
{
|
|
||||||
$push: {
|
|
||||||
deletedDocs: {
|
|
||||||
_id: this.doc._id,
|
|
||||||
name: this.doc.name,
|
|
||||||
deletedAt: sinon.match.date
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.chain('exec')
|
|
||||||
.resolves()
|
|
||||||
await this.subject.promises._insertDeletedDocReference(
|
|
||||||
this.project._id,
|
|
||||||
this.doc
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should update the database', function() {
|
|
||||||
this.ProjectMock.verify()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('_insertDeletedFileReference', function() {
|
describe('_insertDeletedFileReference', function() {
|
||||||
beforeEach(async function() {
|
beforeEach(async function() {
|
||||||
this.DeletedFileMock.expects('create')
|
this.DeletedFileMock.expects('create')
|
||||||
|
|
|
@ -114,7 +114,6 @@ describe('ProjectEntityUpdateHandler', function() {
|
||||||
_confirmFolder: sinon.stub(),
|
_confirmFolder: sinon.stub(),
|
||||||
_putElement: sinon.stub(),
|
_putElement: sinon.stub(),
|
||||||
_insertDeletedFileReference: sinon.stub(),
|
_insertDeletedFileReference: sinon.stub(),
|
||||||
_insertDeletedDocReference: sinon.stub(),
|
|
||||||
replaceFileWithNew: sinon.stub(),
|
replaceFileWithNew: sinon.stub(),
|
||||||
mkdirp: sinon.stub(),
|
mkdirp: sinon.stub(),
|
||||||
moveEntity: sinon.stub(),
|
moveEntity: sinon.stub(),
|
||||||
|
@ -2157,7 +2156,6 @@ describe('ProjectEntityUpdateHandler', function() {
|
||||||
}
|
}
|
||||||
this.path = '/path/to/doc'
|
this.path = '/path/to/doc'
|
||||||
this.ProjectEntityUpdateHandler.unsetRootDoc = sinon.stub().yields()
|
this.ProjectEntityUpdateHandler.unsetRootDoc = sinon.stub().yields()
|
||||||
this.ProjectEntityMongoUpdateHandler._insertDeletedDocReference.yields()
|
|
||||||
this.DocstoreManager.deleteDoc.yields()
|
this.DocstoreManager.deleteDoc.yields()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2185,12 +2183,6 @@ describe('ProjectEntityUpdateHandler', function() {
|
||||||
.should.equal(true)
|
.should.equal(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should insert the doc into the deletedDocs array', function() {
|
|
||||||
this.ProjectEntityMongoUpdateHandler._insertDeletedDocReference
|
|
||||||
.calledWith(this.project._id, this.doc)
|
|
||||||
.should.equal(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should delete the doc in the doc store', function() {
|
it('should delete the doc in the doc store', function() {
|
||||||
this.DocstoreManager.deleteDoc
|
this.DocstoreManager.deleteDoc
|
||||||
.calledWith(projectId, this.doc._id.toString(), 'test.tex')
|
.calledWith(projectId, this.doc._id.toString(), 'test.tex')
|
||||||
|
|
Loading…
Reference in a new issue