Merge pull request #4078 from overleaf/em-restore-deleted-docs

Fix restore_soft_deleted_docs script

GitOrigin-RevId: c21ea407ed9f6fb969b36d5452f38e446eff1c8b
This commit is contained in:
Jakob Ackermann 2021-05-21 13:32:30 +02:00 committed by Copybot
parent da782bdcfa
commit 26dbae7cef

View file

@ -1,7 +1,7 @@
const { waitForDb } = require('../app/src/infrastructure/mongodb')
const ProjectEntityUpdateHandler = require('../app/src/Features/Project/ProjectEntityUpdateHandler')
const ProjectEntityHandler = require('../app/src/Features/Project/ProjectEntityHandler')
const ProjectGetter = require('../app/src/Features/Project/ProjectGetter')
const DocstoreManager = require('../app/src/Features/Docstore/DocstoreManager')
const Path = require('path')
const ARGV = process.argv.slice(2)
@ -10,10 +10,10 @@ const PROJECT_ID = ARGV.shift()
const FILE_NAMES_TO_RESTORE = ARGV
async function main() {
const project = await ProjectGetter.promises.getProject(PROJECT_ID, {
deletedDocs: 1,
})
const docsToRestore = project.deletedDocs.filter(doc =>
const deletedDocs = await DocstoreManager.promises.getAllDeletedDocs(
PROJECT_ID
)
const docsToRestore = deletedDocs.filter(doc =>
FILE_NAMES_TO_RESTORE.includes(doc.name)
)
for (const deletedDoc of docsToRestore) {