Allow setup without backup archive

This commit is contained in:
Manuel Thalmann 2023-06-18 20:11:49 +02:00
parent b40ba593a3
commit 0a5c50a446

View file

@ -34,7 +34,7 @@ function Invoke-WindowsRestore([Context] $context) {
{ {
$backupPath = Read-Host -Prompt "Please enter the path to the archive load the backup from."; $backupPath = Read-Host -Prompt "Please enter the path to the archive load the backup from.";
if (-not (Test-Path -PathType Leaf $backupPath)) if (-not $backupPath -or (-not (Test-Path -PathType Leaf $backupPath)))
{ {
Write-Host "No file could be found at the specified path."; Write-Host "No file could be found at the specified path.";
return Read-Path; return Read-Path;
@ -45,6 +45,15 @@ function Invoke-WindowsRestore([Context] $context) {
$context = [Context]::new(); $context = [Context]::new();
$context.BackupName ??= "PortValhalla"; $context.BackupName ??= "PortValhalla";
$context.RootDir = $context.GetTempDirectory(); $context.RootDir = $context.GetTempDirectory();
if (-not $backupPath)
{
New-Item -ItemType Directory "$backupPath";
}
else
{
$context.Restore($backupPath, $context.BackupRoot()); $context.Restore($backupPath, $context.BackupRoot());
}
Remove-Item -Recurse $context.RootDir; Remove-Item -Recurse $context.RootDir;
} }