Browse Source

getzig add powershell GC (garbage collection) calls to fix intermittent locking problem after zip extraction

master
Julian Noble 4 months ago
parent
commit
6ed7d13594
  1. 22
      bin/getzig.cmd
  2. 22
      src/scriptapps/getzig.ps1

22
bin/getzig.cmd

@ -944,6 +944,11 @@ if ($mirrors_response.StatusCode -eq 200) {
write-host "host_list: $host_list" write-host "host_list: $host_list"
$automation_name = "punkshell+julian@precisium.com.au_target_by_latency" $automation_name = "punkshell+julian@precisium.com.au_target_by_latency"
#test-netconnection progressbar seems not-so-well-behaved (prog bar lingers)
#test-netconnection a function not cmdlet? Seems to need setting at global level
$OriginalProgressPreference = $Global:ProgressPreference
$Global:ProgressPreference = 'SilentlyContinue'
#temporary dev download source #temporary dev download source
$ihost = "10.30.30.107" $ihost = "10.30.30.107"
$imirror = "http://10.30.30.107/jn/punkbin/raw/branch/master/win64/tools" $imirror = "http://10.30.30.107/jn/punkbin/raw/branch/master/win64/tools"
@ -954,9 +959,9 @@ if ($mirrors_response.StatusCode -eq 200) {
$dict_mirrors[$ihost]["latency"] = 1 $dict_mirrors[$ihost]["latency"] = 1
$dict_mirrors[$ihost]["uri"] = $imirror $dict_mirrors[$ihost]["uri"] = $imirror
} }
$trace = test-netconnection gitea1.intx.com.au -Hops 6 -TraceRoute -ErrorAction Ignore $trace = test-netconnection gitea1.intx.com.au -Hops 6 -TraceRoute -ErrorAction Ignore
$Global:ProgressPreference = $OriginalProgressPreference
if ((${trace}.PingSucceeded) -and (${trace}.TraceRoute.Count -lt 5)) { if ((${trace}.PingSucceeded) -and (${trace}.TraceRoute.Count -lt 5)) {
$dict_mirrors["gitea1.intx.com.au"]["latency"] = 2 $dict_mirrors["gitea1.intx.com.au"]["latency"] = 2
#short-circuit for hosts very near gitea1.intx.com.au #short-circuit for hosts very near gitea1.intx.com.au
@ -1065,15 +1070,22 @@ if ($mirrors_response.StatusCode -eq 200) {
Write-Host "Signature OK - extracting archive ..." Write-Host "Signature OK - extracting archive ..."
#Expand-Archive -path $outfile -DestinationPath $toolsfolder -Force #This is *insanely* (many minutes vs seconds) slow on powershell 5 at least - we get a progress meter, but it's too high a price to pay. #Expand-Archive -path $outfile -DestinationPath $toolsfolder -Force #This is *insanely* (many minutes vs seconds) slow on powershell 5 at least - we get a progress meter, but it's too high a price to pay.
# -------------------------------------
Add-Type -Assembly "System.IO.Compression.Filesystem" Add-Type -Assembly "System.IO.Compression.Filesystem"
[System.IO.Compression.Zipfile]::ExtractToDirectory($releasearchive,$toolsfolder) [System.IO.Compression.Zipfile]::ExtractToDirectory($outfile, $toolsfolder)
Write-Host " - archive extracted." Write-Host " - archive extracted."
#We *intermittently* get permission errors when trying to rename the resulting folder (possibly also if we try to delete the zip file immediately)
#There seems to be some sort of lock held after ExtractToDirectory (possibly AV related)
#https://stackoverflow.com/questions/74582293/file-lock-issues-on-zip-file-after-io-compression-zipfileextracttodirectory
[GC]::Collect()
[GC]::WaitForPendingFinalizers()
# -------------------------------------
#Remove-Item -Path "$outfile" #Remove-Item -Path "$outfile"
$zip_rootname = [System.IO.Path]::GetFileNameWithoutExtension($releasearchive) $zip_rootname = [System.IO.Path]::GetFileNameWithoutExtension($releasearchive)
#Rename-Item -Path #Rename-Item -Path
write-host "zip_rootname: $zip_rootname" #write-host "zip_rootname: $zip_rootname"
write-host "moving $(Join-Path -Path $toolsfolder -ChildPath $zip_rootname) to ${zigfolder}"
Rename-Item -Path $(Join-Path -Path $toolsfolder -ChildPath $zip_rootname) -NewName $zigfolder Rename-Item -Path $(Join-Path -Path $toolsfolder -ChildPath $zip_rootname) -NewName $zigfolder
Write-Host "Zig installed in ${zigfolder}" Write-Host "Zig installed in ${zigfolder}"
$zigexe = Join-Path $zigfolder -ChildPath "zig.exe" $zigexe = Join-Path $zigfolder -ChildPath "zig.exe"

22
src/scriptapps/getzig.ps1

@ -110,6 +110,11 @@ if ($mirrors_response.StatusCode -eq 200) {
write-host "host_list: $host_list" write-host "host_list: $host_list"
$automation_name = "punkshell+julian@precisium.com.au_target_by_latency" $automation_name = "punkshell+julian@precisium.com.au_target_by_latency"
#test-netconnection progressbar seems not-so-well-behaved (prog bar lingers)
#test-netconnection a function not cmdlet? Seems to need setting at global level
$OriginalProgressPreference = $Global:ProgressPreference
$Global:ProgressPreference = 'SilentlyContinue'
#temporary dev download source #temporary dev download source
$ihost = "10.30.30.107" $ihost = "10.30.30.107"
$imirror = "http://10.30.30.107/jn/punkbin/raw/branch/master/win64/tools" $imirror = "http://10.30.30.107/jn/punkbin/raw/branch/master/win64/tools"
@ -120,9 +125,9 @@ if ($mirrors_response.StatusCode -eq 200) {
$dict_mirrors[$ihost]["latency"] = 1 $dict_mirrors[$ihost]["latency"] = 1
$dict_mirrors[$ihost]["uri"] = $imirror $dict_mirrors[$ihost]["uri"] = $imirror
} }
$trace = test-netconnection gitea1.intx.com.au -Hops 6 -TraceRoute -ErrorAction Ignore $trace = test-netconnection gitea1.intx.com.au -Hops 6 -TraceRoute -ErrorAction Ignore
$Global:ProgressPreference = $OriginalProgressPreference
if ((${trace}.PingSucceeded) -and (${trace}.TraceRoute.Count -lt 5)) { if ((${trace}.PingSucceeded) -and (${trace}.TraceRoute.Count -lt 5)) {
$dict_mirrors["gitea1.intx.com.au"]["latency"] = 2 $dict_mirrors["gitea1.intx.com.au"]["latency"] = 2
#short-circuit for hosts very near gitea1.intx.com.au #short-circuit for hosts very near gitea1.intx.com.au
@ -231,15 +236,22 @@ if ($mirrors_response.StatusCode -eq 200) {
Write-Host "Signature OK - extracting archive ..." Write-Host "Signature OK - extracting archive ..."
#Expand-Archive -path $outfile -DestinationPath $toolsfolder -Force #This is *insanely* (many minutes vs seconds) slow on powershell 5 at least - we get a progress meter, but it's too high a price to pay. #Expand-Archive -path $outfile -DestinationPath $toolsfolder -Force #This is *insanely* (many minutes vs seconds) slow on powershell 5 at least - we get a progress meter, but it's too high a price to pay.
# -------------------------------------
Add-Type -Assembly "System.IO.Compression.Filesystem" Add-Type -Assembly "System.IO.Compression.Filesystem"
[System.IO.Compression.Zipfile]::ExtractToDirectory($releasearchive,$toolsfolder) [System.IO.Compression.Zipfile]::ExtractToDirectory($outfile, $toolsfolder)
Write-Host " - archive extracted." Write-Host " - archive extracted."
#We *intermittently* get permission errors when trying to rename the resulting folder (possibly also if we try to delete the zip file immediately)
#There seems to be some sort of lock held after ExtractToDirectory (possibly AV related)
#https://stackoverflow.com/questions/74582293/file-lock-issues-on-zip-file-after-io-compression-zipfileextracttodirectory
[GC]::Collect()
[GC]::WaitForPendingFinalizers()
# -------------------------------------
#Remove-Item -Path "$outfile" #Remove-Item -Path "$outfile"
$zip_rootname = [System.IO.Path]::GetFileNameWithoutExtension($releasearchive) $zip_rootname = [System.IO.Path]::GetFileNameWithoutExtension($releasearchive)
#Rename-Item -Path #Rename-Item -Path
write-host "zip_rootname: $zip_rootname" #write-host "zip_rootname: $zip_rootname"
write-host "moving $(Join-Path -Path $toolsfolder -ChildPath $zip_rootname) to ${zigfolder}"
Rename-Item -Path $(Join-Path -Path $toolsfolder -ChildPath $zip_rootname) -NewName $zigfolder Rename-Item -Path $(Join-Path -Path $toolsfolder -ChildPath $zip_rootname) -NewName $zigfolder
Write-Host "Zig installed in ${zigfolder}" Write-Host "Zig installed in ${zigfolder}"
$zigexe = Join-Path $zigfolder -ChildPath "zig.exe" $zigexe = Join-Path $zigfolder -ChildPath "zig.exe"

Loading…
Cancel
Save