Added actor flush, renamed inconsistent actor flush to actor delete.
This commit is contained in:
@@ -8,6 +8,7 @@ const blake2 = require('blake2');
|
||||
const DOMPurify = require('dompurify');
|
||||
const { JSDOM } = require('jsdom');
|
||||
const omit = require('object.omit');
|
||||
const inquirer = require('inquirer');
|
||||
|
||||
const { window } = new JSDOM('');
|
||||
const domPurify = DOMPurify(window);
|
||||
@@ -973,7 +974,7 @@ async function flushProfiles(actorIdsOrNames) {
|
||||
logger.info(`Removed ${deleteCount} profiles`);
|
||||
}
|
||||
|
||||
async function flushActors(actorIdsOrNames) {
|
||||
async function deleteActors(actorIdsOrNames) {
|
||||
const actors = await knex('actors')
|
||||
.whereIn('id', actorIdsOrNames.filter(idOrName => typeof idOrName === 'number'))
|
||||
.orWhere((builder) => {
|
||||
@@ -1002,8 +1003,31 @@ async function flushActors(actorIdsOrNames) {
|
||||
logger.info(`Removed ${deletedActorsCount} actors with ${deletedScenesCount} scenes`);
|
||||
}
|
||||
|
||||
async function flushActors() {
|
||||
const actorIds = await knex('actors').select('id').pluck('id');
|
||||
|
||||
const confirmed = await inquirer.prompt([{
|
||||
type: 'confirm',
|
||||
name: 'flushActors',
|
||||
message: `You are about to remove ${actorIds.length} actors. Are you sure?`,
|
||||
default: false,
|
||||
}]);
|
||||
|
||||
if (!confirmed.flushActors) {
|
||||
logger.warn('Confirmation rejected, not flushing actors');
|
||||
return;
|
||||
}
|
||||
|
||||
const deleteCount = await deleteActors(actorIds);
|
||||
|
||||
await flushOrphanedMedia();
|
||||
|
||||
logger.info(`Removed ${deleteCount}/${actorIds.length} actors`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
associateActors,
|
||||
deleteActors,
|
||||
fetchActor,
|
||||
flushActors,
|
||||
flushProfiles,
|
||||
|
||||
Reference in New Issue
Block a user