diff --git a/services/docstore/app.js b/services/docstore/app.js index bd04f6647f..790a916f33 100644 --- a/services/docstore/app.js +++ b/services/docstore/app.js @@ -87,8 +87,6 @@ app.use(function (error, req, res, next) { logger.error({ err: error, req }, 'request errored') if (error instanceof Errors.NotFoundError) { return res.sendStatus(404) - } else if (error instanceof Errors.InvalidOperation) { - return res.status(400).send(error.message) } else { return res.status(500).send('Oops, something went wrong') } diff --git a/services/docstore/app/js/DocManager.js b/services/docstore/app/js/DocManager.js index 648bc8d944..2f19087388 100644 --- a/services/docstore/app/js/DocManager.js +++ b/services/docstore/app/js/DocManager.js @@ -336,12 +336,6 @@ module.exports = DocManager = { ) } - // deletion is a one-way operation - if (doc.deleted) - return callback( - new Errors.InvalidOperation('Cannot PATCH after doc deletion') - ) - if (meta.deleted && Settings.docstore.archiveOnSoftDelete) { // The user will not read this doc anytime soon. Flush it out of mongo. DocArchive.archiveDocById(project_id, doc_id, (err) => { diff --git a/services/docstore/app/js/Errors.js b/services/docstore/app/js/Errors.js index 1b9332b4a0..6a74485494 100644 --- a/services/docstore/app/js/Errors.js +++ b/services/docstore/app/js/Errors.js @@ -4,10 +4,7 @@ const { Errors } = require('@overleaf/object-persistor') class Md5MismatchError extends OError {} -class InvalidOperation extends OError {} - module.exports = { Md5MismatchError, - InvalidOperation, ...Errors } diff --git a/services/docstore/test/acceptance/js/DeletingDocsTests.js b/services/docstore/test/acceptance/js/DeletingDocsTests.js index 3872a62762..27d3c212c7 100644 --- a/services/docstore/test/acceptance/js/DeletingDocsTests.js +++ b/services/docstore/test/acceptance/js/DeletingDocsTests.js @@ -212,43 +212,6 @@ describe('Delete via DELETE', function () { describe('Delete via PATCH', function () { deleteTestSuite(DocstoreClient.deleteDoc) - describe('deleting a doc twice', function () { - beforeEach('perform 1st DELETE request', function (done) { - DocstoreClient.deleteDoc(this.project_id, this.doc_id, done) - }) - - beforeEach('get doc before 2nd DELETE request', function (done) { - db.docs.find({ _id: this.doc_id }).toArray((error, docs) => { - if (error) return done(error) - this.docBefore = docs[0] - if (!this.docBefore) return done(new Error('doc not found')) - done() - }) - }) - - beforeEach('perform 2nd DELETE request', function (done) { - DocstoreClient.deleteDoc(this.project_id, this.doc_id, (error, res) => { - this.res1 = res - done(error) - }) - }) - - it('should reject the 2nd request', function () { - expect(this.res1.statusCode).to.equal(400) - }) - - it('should not alter the previous doc state', function (done) { - db.docs.find({ _id: this.doc_id }).toArray((error, docs) => { - if (error) return done(error) - const docAfter = docs[0] - if (!docAfter) return done(new Error('doc not found')) - - expect(docAfter).to.deep.equal(this.docBefore) - done() - }) - }) - }) - describe('when providing a custom doc name in the delete request', function () { beforeEach(function (done) { DocstoreClient.deleteDocWithName( diff --git a/services/docstore/test/unit/js/DocManagerTests.js b/services/docstore/test/unit/js/DocManagerTests.js index d581ce743b..50caa69501 100644 --- a/services/docstore/test/unit/js/DocManagerTests.js +++ b/services/docstore/test/unit/js/DocManagerTests.js @@ -689,33 +689,6 @@ describe('DocManager', function () { }) }) - describe('when the doc is already deleted', function () { - beforeEach(function (done) { - this.MongoManager.findDoc = sinon - .stub() - .yields(null, { _id: ObjectId(this.doc_id), deleted: true }) - this.MongoManager.patchDoc = sinon.stub() - - this.callback = sinon.stub().callsFake(() => done()) - this.DocManager.patchDoc( - this.project_id, - this.doc_id, - 'tomato.tex', - this.callback - ) - }) - - it('should reject the operation', function () { - expect(this.callback).to.have.been.calledWith( - sinon.match.has('message', 'Cannot PATCH after doc deletion') - ) - }) - - it('should not persist the change to mongo', function () { - expect(this.MongoManager.patchDoc).to.not.have.been.called - }) - }) - describe('when the doc does not exist', function () { beforeEach(function () { this.MongoManager.findDoc = sinon.stub().yields(null)