Skip to content

Commit

Permalink
don't delete if missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioMendolia committed Sep 24, 2023
1 parent 9b08c38 commit fc73865
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Command/BooksScanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Command;

use App\Entity\Book;
use App\Repository\BookRepository;
use App\Service\BookFileSystemManager;
use App\Service\BookManager;
Expand Down Expand Up @@ -102,8 +103,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$progressBar = new ProgressBar($output, count($unprocessedBooks));
$progressBar->start();
foreach ($unprocessedBooks as $book) {
/* @var Book $book */
$progressBar->advance();
$this->entityManager->remove($book);
if (!str_starts_with($book->getTitle(), '[Missing File] ')) {
$book->setTitle('[Missing File] '.$book->getTitle());
$this->entityManager->flush();
}
}
$progressBar->finish();
$io->writeln('Removing books...');
Expand Down

0 comments on commit fc73865

Please sign in to comment.