Merge pull request #7627 from overleaf/em-docstore-archiving

Safer doc unarchiving

GitOrigin-RevId: 60f7aa39401d2f09c13570097c4f376cc401931f
This commit is contained in:
Eric Mc Sween
2022-04-27 08:03:57 +00:00
committed by Copybot
parent 40bbaf168b
commit ddb94d159a
9 changed files with 500 additions and 447 deletions
+7 -3
View File
@@ -2,6 +2,7 @@ const DocManager = require('./DocManager')
const logger = require('@overleaf/logger')
const DocArchive = require('./DocArchiveManager')
const HealthChecker = require('./HealthChecker')
const Errors = require('./Errors')
const Settings = require('@overleaf/settings')
function getDoc(req, res, next) {
@@ -250,16 +251,19 @@ function unArchiveAllDocs(req, res, next) {
logger.log({ projectId }, 'unarchiving all docs')
DocArchive.unArchiveAllDocs(projectId, function (error) {
if (error) {
if (error instanceof Errors.DocRevValueError) {
return res.sendStatus(409)
}
return next(error)
}
res.sendStatus(200)
})
}
function destroyAllDocs(req, res, next) {
function destroyProject(req, res, next) {
const { project_id: projectId } = req.params
logger.log({ projectId }, 'destroying all docs')
DocArchive.destroyAllDocs(projectId, function (error) {
DocArchive.destroyProject(projectId, function (error) {
if (error) {
return next(error)
}
@@ -291,6 +295,6 @@ module.exports = {
archiveAllDocs,
archiveDoc,
unArchiveAllDocs,
destroyAllDocs,
destroyProject,
healthCheck,
}