From f071f85508871c3db4db6e23b1b55e56aabaac64 Mon Sep 17 00:00:00 2001 From: Florian Moser Date: Mon, 18 Sep 2023 09:04:27 +0200 Subject: [PATCH] fix: Fix duplicate file detection --- src/Service/Report/Pdf/PdfService.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Service/Report/Pdf/PdfService.php b/src/Service/Report/Pdf/PdfService.php index 72e040e7..eceecb6b 100644 --- a/src/Service/Report/Pdf/PdfService.php +++ b/src/Service/Report/Pdf/PdfService.php @@ -92,8 +92,10 @@ public function generatePdfReport(array $issues, Filter $filter, ReportElements $sanitizedConstructionSiteName = FileHelper::sanitizeFileName($constructionSite->getName()); $humanReadablePrefix = (new \DateTime())->format(DateTimeFormatter::FILESYSTEM_DATE_TIME_FORMAT).'_'.$sanitizedConstructionSiteName; + $optimalFilename = $humanReadablePrefix.'.pdf'; - $filename = file_exists($optimalFilename) ? $humanReadablePrefix.'_'.uniqid().'.pdf' : $optimalFilename; + $optimalPath = $folder.'/'.$optimalFilename; + $filename = file_exists($optimalPath) ? $humanReadablePrefix.'_'.uniqid().'.pdf' : $optimalFilename; $path = $folder.'/'.$filename; $report->save($path);