<commit_before><?php

declare(strict_types=1);

namespace Mwop\Art\Console;

use League\Flysystem\FilesystemOperator;
use League\Flysystem\MountManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;

class FetchPhotoDatabase extends Command
{
    private MountManager $filesystem;

    public function __construct(
        FilesystemOperator $app,
        FilesystemOperator $remote,
        private string $database,
    ) {
        $this->filesystem = new MountManager([
            'app'    => $app,
            'remote' => $remote,
        ]);
        parent::__construct();
    }

    protected function configure()
    {
        $this->setDescription('Fetch the remote photo database for use locally');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        try {
            $this->filesystem->copy('remote://' . $this->database, 'app://' . $this->database);
        } catch (Throwable $e) {
            $output->writeln('<error>Failed to fetch remote photo database for local use</error>');
            $output->writeln($e->getMessage());
            $output->writeln($e->getTraceAsString());
            return 1;
        }

        return 0;
    }
}<commit_msg>qa: allow getting more detailed information when photo database fetching fails<commit_after><?php

declare(strict_types=1);

namespace Mwop\Art\Console;

use League\Flysystem\FilesystemOperator;
use League\Flysystem\MountManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;

class FetchPhotoDatabase extends Command
{
    private MountManager $filesystem;

    public function __construct(
        FilesystemOperator $app,
        FilesystemOperator $remote,
        private string $database,
    ) {
        $this->filesystem = new MountManager([
            'app'    => $app,
            'remote' => $remote,
        ]);
        parent::__construct();
    }

    protected function configure()
    {
        $this->setDescription('Fetch the remote photo database for use locally');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        try {
            $this->filesystem->copy('remote://' . $this->database, 'app://' . $this->database);
        } catch (Throwable $e) {
            $output->writeln('<error>Failed to fetch remote photo database for local use</error>');
            do {
                $output->writeln($e->getMessage());
                $output->writeln($e->getTraceAsString());
                $e = $e->getPrevious();
            } while ($e);

            return 1;
        }

        return 0;
    }
}
{'fraction_non_alphanumeric': 0.12135068589518115, 'fraction_numerical': 0.002110446711220542, 'mean_word_length': 2.6137229987293518, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6330227', 'n_tokens_mistral': 771, 'n_tokens_neox': 753, 'n_words': 179}