diff options
author | Heikki Halmet <heikki.halmet@qt.io> | 2019-02-15 13:28:47 +0200 |
---|---|---|
committer | Heikki Halmet <heikki.halmet@qt.io> | 2019-11-28 10:30:32 +0200 |
commit | 58cfa8f0b11be1f7f5c6b6b247c074df972c6e97 (patch) | |
tree | d17bf2173b6aae1b832dcbade7c31bec2dfb539a | |
parent | a8ef3e016a317f3c91de46d9ed1c86f99275993f (diff) | |
download | qt5-58cfa8f0b11be1f7f5c6b6b247c074df972c6e97.tar.gz |
Provisioning: Help script for removing items
Sometimes items are locked (access denied) so we need to have function
which waits and retry until removing is possible.
Task-number: QTQAINFRA-2806
Change-Id: I09055c45c0e439ed1a20eb575ee79b7ca22c5745
(cherry picked from commit 76c80866af78274eeb973ab38ad7b44f216b1a1e)
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
-rw-r--r-- | coin/provisioning/common/windows/helpers.ps1 | 19 | ||||
-rw-r--r-- | coin/provisioning/common/windows/vc_redist.ps1 | 3 |
2 files changed, 20 insertions, 2 deletions
diff --git a/coin/provisioning/common/windows/helpers.ps1 b/coin/provisioning/common/windows/helpers.ps1 index 71a63217..ee3a4038 100644 --- a/coin/provisioning/common/windows/helpers.ps1 +++ b/coin/provisioning/common/windows/helpers.ps1 @@ -160,3 +160,22 @@ function isProxyEnabled { function getProxy { return (Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').proxyServer } + +function Remove { + + Param ( + [string]$Path = $(BadParam("a path")) + ) + Write-Host "Removing $Path" + $i = 0 + While ( Test-Path($Path) ){ + Try{ + remove-item -Force -Recurse -Path $Path -ErrorAction Stop + }catch{ + $i +=1 + if ($i -eq 5) {exit 1} + Write-Verbose "$Path locked, trying again in 5" + Start-Sleep -seconds 5 + } + } +} diff --git a/coin/provisioning/common/windows/vc_redist.ps1 b/coin/provisioning/common/windows/vc_redist.ps1 index c356ca2c..d939011f 100644 --- a/coin/provisioning/common/windows/vc_redist.ps1 +++ b/coin/provisioning/common/windows/vc_redist.ps1 @@ -57,5 +57,4 @@ Download $externalUrl $internalUrl $package Verify-Checksum $package $sha1 Write-Host "Installing $package..." Run-Executable $package "/q" -Write-Host "Remove $package..." -Remove-Item -Force -Path $package +Remove $package |