mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
26f3f3e2e2
Migrate scripts folder to esm 1/x GitOrigin-RevId: 4a4bc9a161f144fdb40ce3f2a0a9313b36c6df81
34 lines
966 B
JavaScript
34 lines
966 B
JavaScript
import { waitForDb } from '../app/src/infrastructure/mongodb.js'
|
|
import ProjectEntityRestoreHandler from '../app/src/Features/Project/ProjectEntityRestoreHandler.js'
|
|
import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.js'
|
|
|
|
const ARGV = process.argv.slice(2)
|
|
const DEVELOPER_USER_ID = ARGV.shift()
|
|
const PROJECT_ID = ARGV.shift()
|
|
const FILE_NAMES_TO_RESTORE = ARGV
|
|
|
|
async function main() {
|
|
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) {
|
|
const newDoc = await ProjectEntityRestoreHandler.promises.restoreDeletedDoc(
|
|
PROJECT_ID,
|
|
deletedDoc._id,
|
|
deletedDoc.name,
|
|
DEVELOPER_USER_ID
|
|
)
|
|
console.log(newDoc)
|
|
}
|
|
}
|
|
|
|
try {
|
|
await waitForDb()
|
|
await main()
|
|
process.exit(0)
|
|
} catch (error) {
|
|
console.error(error)
|
|
process.exit(1)
|
|
}
|