]> _ Git - cubist_util.git/commitdiff
wip #5093 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 15 Feb 2022 14:07:44 +0000 (15:07 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 15 Feb 2022 14:07:44 +0000 (15:07 +0100)
src/Zip.php

index edf3896c5f63cd3d55308a2ab1ef82e374c6e11e..149cb80bec983bcb8d70627307c460ce3492a399 100644 (file)
@@ -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();