From e7ea1b99db9d112c464d046d8ebdadd4d3535405 Mon Sep 17 00:00:00 2001 From: Janos Pribelszki Date: Mon, 6 Nov 2023 18:23:58 +0100 Subject: [PATCH] feature: Added logging of zip export create errors. --- model/ZipExporter.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/model/ZipExporter.php b/model/ZipExporter.php index 2b53fc8c3..7f9a5cbeb 100644 --- a/model/ZipExporter.php +++ b/model/ZipExporter.php @@ -148,22 +148,23 @@ private function getSavePath(string $unsafePath): string */ protected function createZipFile($filename, array $exportClasses = [], array $exportFiles = []): string { - $baseDir = tao_helpers_Export::getExportPath(); - $path = $baseDir . '/' . $filename . '.zip'; + try { + $errors = []; - $zip = new ZipArchive(); - if ($zip->open($path, ZipArchive::CREATE) !== true) { - throw new common_Exception('Unable to create zipfile ' . $path); - } + $baseDir = tao_helpers_Export::getExportPath(); + $path = $baseDir . '/' . $filename . '.zip'; - if ($zip->numFiles !== 0) { - $zip->close(); + $zip = new ZipArchive(); + if ($zip->open($path, ZipArchive::CREATE) !== true) { + throw new common_Exception('Unable to create zipfile ' . $path); + } - return $path; - } + if ($zip->numFiles !== 0) { + $zip->close(); + + return $path; + } - try { - $errors = []; foreach ($exportFiles as $label => $files) { $archivePath = '';