diff --git a/src/Controller/Administrative/Document/BatchDownloadController.php b/src/Controller/Administrative/Document/BatchDownloadController.php index c8eb691..220e49a 100644 --- a/src/Controller/Administrative/Document/BatchDownloadController.php +++ b/src/Controller/Administrative/Document/BatchDownloadController.php @@ -6,6 +6,7 @@ use App\Entity\Upload; use App\Repository\UploadRepository; use App\Service\Upload\UploadHandler; use Doctrine\ORM\EntityManagerInterface; +use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\HeaderUtils; use Symfony\Component\HttpFoundation\Response; @@ -21,7 +22,8 @@ class BatchDownloadController extends AbstractController public function __construct( private readonly UploadRepository $uploadRepository, private readonly UploadHandler $uploadHandler, - private readonly EntityManagerInterface $entityManager + private readonly EntityManagerInterface $entityManager, + private readonly LoggerInterface $logger, ) { } @@ -72,14 +74,18 @@ class BatchDownloadController extends AbstractController ->setDownloaded() ->setDownloadedBy($this->getUser()->getUserIdentifier()) ; - } catch (FileNotFoundException $e) { - } catch (FileNotReadableException $e) { + } catch (FileNotFoundException|FileNotReadableException $e) { + $this->logger->error('Unable to add file to ZIP', [ + 'upload' => $upload->getUuid(), + 'error' => $e->getMessage(), + ]); } } $zip->finish(); - $this->entityManager->flush(); }); + $this->entityManager->flush(); + $disposition = HeaderUtils::makeDisposition('attachment', $zipFilename, md5($zipFilename)); $response->headers->set('Content-Disposition', $disposition);