Merge pull request #4252 from overleaf/em-active-projects-expire

Prevent active projects from expiring

GitOrigin-RevId: b815ef2022470cc1ec4dc47fb1b13563b230814f
This commit is contained in:
Eric Mc Sween
2021-06-24 02:07:24 +00:00
committed by Copybot
parent 9b9d6f679e
commit 8462a3e1f5
2 changed files with 22 additions and 0 deletions
@@ -342,6 +342,16 @@ async function undeleteProject(projectId, options = {}) {
async function expireDeletedProject(projectId) {
try {
const activeProject = await Project.findById(projectId).exec()
if (activeProject) {
// That project is active. The deleted project record might be there
// because of an incomplete delete or undelete operation. Clean it up and
// return.
await DeletedProject.deleteOne({
'deleterData.deletedProjectId': projectId,
})
return
}
const deletedProject = await DeletedProject.findOne({
'deleterData.deletedProjectId': projectId,
}).exec()