Fixed orphaned media flush running on every startup.

This commit is contained in:
DebaucheryLibrarian 2025-05-29 02:38:13 +02:00
parent 3a0e815387
commit 91c490d153
2 changed files with 5 additions and 1 deletions

View File

@ -323,7 +323,6 @@ const { argv } = yargs
describe: 'Remove all orphaned media items from database and disk.',
type: 'boolean',
alias: 'flush-media',
default: config.media.flushOrphaned,
})
.option('flush-media-files', {
describe: 'Remove files from storage when flushing media.',

View File

@ -1056,6 +1056,11 @@ async function deleteS3Objects(allMedia) {
}
async function flushOrphanedMedia(stage = 1) {
if (!config.media.flushOrphaned) {
logger.verbose('Orphaned media flush skipped, disabled in config');
return;
}
logger.info(`Flushing orphaned media, stage ${stage}`);
const orphanedMedia = await knex('media')