Merge pull request #33023 from overleaf/copilot/add-warning-for-unprocessed-projects

Clarify clear_deleted.js completion output for force mode and partial processing

GitOrigin-RevId: 11d9595e5b43bb8df8e1c7f664f4c08c3fbd4509
This commit is contained in:
Brian Gough
2026-04-27 11:13:35 +01:00
committed by Copybot
parent 8a331bc943
commit e6861ab6fa

View File

@@ -4,6 +4,7 @@ import async from 'async'
import logger from '@overleaf/logger'
import Settings from '@overleaf/settings'
import redis from '@overleaf/redis-wrapper'
import path from 'node:path'
import { db, ObjectId } from '../app/js/mongodb.js'
logger.logger.level('fatal')
@@ -118,7 +119,7 @@ main().catch(error => {
})
function processFailures(results) {
if (argv.length === 0) {
if (limit === null) {
console.log(`
Usage: node clear_deleted.js [QUEUES] [FORCE]
@@ -126,11 +127,28 @@ where
QUEUES is the number of queues to process
FORCE is the string "force" when we're ready to delete the queues. Without it, this script does a dry-run
`)
process.exit(0)
}
console.log('number of stuck projects', results.length)
console.log('force mode', force ? 'enabled' : 'disabled (dry run)')
const projectsToProcess = results.slice(0, limit)
const unprocessedProjects = results.length - projectsToProcess.length
const scriptFileName = path.basename(process.argv[1])
const limitOrPlaceholder = limit ?? 100
const forceExampleCommand = `node scripts/${scriptFileName} ${limitOrPlaceholder} force`
// now check if the project is truly deleted in mongo
async.eachSeries(results.slice(0, limit), checkAndClear, err => {
async.eachSeries(projectsToProcess, checkAndClear, err => {
console.log('DONE', err)
if (unprocessedProjects > 0) {
console.warn(
`WARNING: ${unprocessedProjects} project(s) were not processed in this run`
)
}
if (!force) {
console.warn(
`Dry run only. Rerun with force to apply changes, for example: ${forceExampleCommand}`
)
}
process.exit()
})
}