Make Copy-Item to throw exception if source does not exist

Copy-Item command does not throw by default. Thus, copying error is
not caught and the Download function returns without downloading from
the official site. Adding "-errorAction stop" makes Copy-Item to throw
an exception as expected in the script.

Change-Id: I889cccac775705613e641453aca9e0197645f344
Reviewed-by: Simo Fält <simo.falt@qt.io>
Reviewed-by: Toni Saario <toni.saario@qt.io>
This commit is contained in:
Piotr Srebrny
2022-04-01 11:56:57 +02:00
parent 30068f2223
commit 9196022e01

View File

@@ -148,7 +148,7 @@ function Download
if ($CachedUrl.StartsWith("http")) {
Invoke-WebRequest -UseBasicParsing $CachedUrl -OutFile $Destination
} else {
Copy-Item $CachedUrl $Destination
Copy-Item $CachedUrl $Destination -errorAction stop
}
} catch {
Write-Host "Cached download failed: Downloading from official location: $OfficialUrl"