]> BookStack Code Mirror - system-cli/blobdiff - scripts/Services/BackupZip.php
Got restore command to a working state
[system-cli] / scripts / Services / BackupZip.php
index 798e2447714f010f156319f7846a8cef9e6b035a..cb3ca280a1600e8bce8fe9eac7a25d5813961fec 100644 (file)
@@ -30,15 +30,15 @@ class BackupZip
             ],
             'themes' => [
                 'desc' => 'Themes Folder',
-                'exists' => $this->zip->locateName('/themes/') !== false,
+                'exists' => $this->hasFolder('themes/'),
             ],
             'public/uploads' => [
                 'desc' => 'Public File Uploads',
-                'exists' => $this->zip->locateName('/public/uploads/') !== false,
+                'exists' => $this->hasFolder('public/uploads/'),
             ],
             'storage/uploads' => [
                 'desc' => 'Private File Uploads',
-                'exists' => $this->zip->locateName('/storage/uploads/') !== false,
+                'exists' => $this->hasFolder('storage/uploads/'),
             ],
             'db' => [
                 'desc' => 'Database Dump',
@@ -54,4 +54,15 @@ class BackupZip
             throw new \Exception("Failed extraction of ZIP into [{$directoryPath}].");
         }
     }
+
+    protected function hasFolder($folderPath): bool
+    {
+        for ($i = 0; $i < $this->zip->numFiles; $i++) {
+            $filePath = $this->zip->getNameIndex($i);
+            if (str_starts_with($filePath, $folderPath)) {
+                return true;
+            }
+        }
+        return false;
+    }
 }