Files
nextcloud-recognize/lib/Command/ResetFaces.php
Marcel Klehr d3625422cb fix(psalm): Upgrade to psalm 6 and fix issues
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-04-09 13:06:24 +02:00

57 lines
1.5 KiB
PHP

<?php
/*
* Copyright (c) 2022 The Recognize contributors.
* This file is licensed under the Affero General Public License version 3 or later. See the COPYING file.
*/
declare(strict_types=1);
namespace OCA\Recognize\Command;
use OCA\Recognize\Db\FaceClusterMapper;
use OCA\Recognize\Db\FaceDetectionMapper;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
final class ResetFaces extends Command {
private FaceDetectionMapper $faceDetectionMapper;
private FaceClusterMapper $clusterMapper;
public function __construct(FaceDetectionMapper $faceDetectionMapper, FaceClusterMapper $clusterMapper) {
parent::__construct();
$this->faceDetectionMapper = $faceDetectionMapper;
$this->clusterMapper = $clusterMapper;
}
/**
* Configure the command
*
* @return void
*/
protected function configure() {
$this->setName('recognize:reset-faces')
->setDescription('Remove all face detections from previously classified files');
}
/**
* Execute the command
*
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
try {
$this->clusterMapper->deleteAll();
$this->faceDetectionMapper->deleteAll();
} catch (\Exception $ex) {
$output->writeln('<error>Failed to reset faces</error>');
$output->writeln($ex->getMessage());
return 1;
}
return 0;
}
}