X-Git-Url: http://source.bookstackapp.com/system-cli/blobdiff_plain/41b30b3b80f4cebe05d847188961f4cc4f1572fd..95c40679e26aa4730cd90c633ec58a2d25971bf4:/scripts/Services/BackupZip.php diff --git a/scripts/Services/BackupZip.php b/scripts/Services/BackupZip.php index 798e244..cb3ca28 100644 --- a/scripts/Services/BackupZip.php +++ b/scripts/Services/BackupZip.php @@ -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; + } }