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();
exec('rm -rf /symlinks');
}
+ public function test_restore_with_invalid_zip_path_shows_warning()
+ {
+ chdir('/var/www/bookstack');
+
+ $result = $this->runCommand('restore', [
+ 'backup-zip' => '/cats/dogs.zip',
+ '--app-directory' => '/var/www/bookstack',
+ ]);
+
+ $result->assertStderrContains("Could not find ZIP file for restoration at provided path [/cats/dogs.zip].");
+ }
+
protected function buildZip(callable $builder): string
{
$zipFile = tempnam(sys_get_temp_dir(), 'cli-test');