From 9ffa903626d21d519301a2e3091bc43ae769d5ca Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 30 Jun 2023 14:15:48 +0200 Subject: [PATCH] Show info if backup archive does not exist --- scripts/Windows/Scripts/Context.ps1 | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index 3d51e6e9..ab1e89ad 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -104,15 +104,25 @@ class Context { } [void] Restore([string]$archivePath, [string]$destinationPath) { - if (-not (Test-Path -PathType Container $destinationPath)) { - New-Item -ItemType Directory "$destinationPath"; + if (-not (Test-Path -PathType Leaf $archivePath)) { + Write-Information ( + [string]::Join( + "`n", + @( + "An archive at the specified path $archivePath does not exist.", + "No restoration will be performed."))); } + else { + if (-not (Test-Path -PathType Container $destinationPath)) { + New-Item -ItemType Directory "$destinationPath"; + } - Start-Process -WorkingDirectory "$destinationPath" ` - -FilePath "7z" - -ArgumentList "x" ` - -Wait ` - -NoNewWindow; + Start-Process -WorkingDirectory "$destinationPath" ` + -FilePath "7z" + -ArgumentList "x" ` + -Wait ` + -NoNewWindow; + } } [string] GetTempDirectory() {