From 907e9ddc9d2ad4699fbed92ea43c9748c72a883a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 15 Feb 2022 15:07:44 +0100 Subject: [PATCH] wip #5093 @0.5 --- src/Zip.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Zip.php b/src/Zip.php index edf3896..149cb80 100644 --- a/src/Zip.php +++ b/src/Zip.php @@ -24,6 +24,21 @@ class Zip } $cl->setArg(null, $zip); $cl->execute(); + + if (stristr($cl->getOutput(), 'zipfile corrupt')) { + $corrupted = $zip . '.corrupted'; + rename($zip, $corrupted); + $cl = new CommandLine('zip'); + $cl->setManualArg('-FF ' . $corrupted); + $cl->setArg('out', $zip); + $cl->execute(); + unlink($corrupted); + if (file_exists($zip . '.zip')) { + rename($zip . '.zip', $zip); + } + return self::extract($zip, $dir, $junkPath); + } + return $cl; // } else if (class_exists('ZipArchive')) { // $za = new \ZipArchive(); -- 2.39.5