diff --git a/commands/par2_prune.ts b/commands/par2_prune.ts new file mode 100644 index 0000000..0ac204c --- /dev/null +++ b/commands/par2_prune.ts @@ -0,0 +1,17 @@ +import { BaseCommand } from '@adonisjs/core/ace' +import type { CommandOptions } from '@adonisjs/core/types/ace' +import db from '@adonisjs/lucid/services/db' +import { Par2Pruner } from '#services/par2_pruner' + +/** The par2 prune (Par2Pruner) in one go: a whole pass from the first set, instead of the merger's 2 minutes an hour. */ +export default class Par2Prune extends BaseCommand { + static commandName = 'par2:prune' + static description = 'Drops the par2 file lists the merge can no longer use: one whole pass over every set, then exits' + static options: CommandOptions = { startApp: true } + + async run() { + await db.from('worker_cursors').where('name', 'par2-prune').update({ key: '' }) + const round = await new Par2Pruner().round() + this.logger.info(`Pruned ${round.rows} par2 file rows: ${round.complete} complete sets, ${round.judged} judged, ${round.final} final.`) + } +}