]> BookStack Code Mirror - system-cli/blobdiff - src/Commands/RestoreCommand.php
Added path check/validation for provided restore file path
[system-cli] / src / Commands / RestoreCommand.php
index 2fa3c853c071931691c303b19ad53485f7f936d7..3fb91540dc8328696ba269741b6714579a5d3deb 100644 (file)
@@ -48,7 +48,13 @@ class RestoreCommand extends Command
         RequirementsValidator::validate();
         (new ProgramRunner('mysql', '/usr/bin/mysql'))->ensureFound();
 
-        $zipPath = realpath($input->getArgument('backup-zip'));
+        $providedZipPath = $input->getArgument('backup-zip');
+        $zipPath = realpath($providedZipPath);
+        if (!$zipPath || !file_exists($zipPath)) {
+            $pathToDisplay = $zipPath ?: $providedZipPath;
+            throw new CommandError("Could not find ZIP file for restoration at provided path [{$pathToDisplay}].");
+        }
+
         $zip = new BackupZip($zipPath);
         $contents = $zip->getContentsOverview();