Skip to content

Commit 223f8ca

Browse files
committed
feat: add extraction progress display for portable Python
- Show directory creation step - Display extraction progress with progress bar - Log archive cleanup step
1 parent 9f2567f commit 223f8ca

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tools/install.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,15 +966,23 @@ function Extract-PortablePython {
966966
}
967967

968968
# Create directory
969+
Write-LogInfo "python_path_creating_dir" $pythonTargetDir
969970
New-Item -ItemType Directory -Path $pythonTargetDir -Force | Out-Null
970971

971972
# Extract zip file, excluding Doc directory
972973
Add-Type -AssemblyName System.IO.Compression.FileSystem
973974
Add-Type -AssemblyName System.IO.Compression
975+
Write-LogInfo "extracting_archive" $archivePath
974976
$zip = [System.IO.Compression.ZipFile]::OpenRead($archivePath)
975977
try {
978+
$totalEntries = ($zip.Entries | Where-Object { $_.FullName -notlike 'Doc/*' -and $_.FullName -ne 'Doc' }).Count
979+
$current = 0
976980
foreach ($entry in $zip.Entries) {
977981
if ($entry.FullName -like 'Doc/*' -or $entry.FullName -eq 'Doc') { continue }
982+
$current++
983+
if ($current % 10 -eq 0 -or $current -eq $totalEntries) {
984+
Write-Progress -Activity "Extracting Python" -Status "File $current of $totalEntries" -PercentComplete (($current / $totalEntries) * 100) -Id 1
985+
}
978986
$entryPath = Join-Path $pythonTargetDir $entry.FullName
979987
if ($entry.Name -eq '') {
980988
# Directory entry
@@ -1001,12 +1009,14 @@ function Extract-PortablePython {
10011009
}
10021010
}
10031011
}
1012+
Write-Progress -Activity "Extracting Python" -Completed -Id 1
10041013
}
10051014
finally {
10061015
$zip.Dispose()
10071016
}
10081017

10091018
# Cleanup archive
1019+
Write-LogInfo "cleanup_archive"
10101020
Remove-Item $archivePath -ErrorAction SilentlyContinue
10111021
}
10121022

0 commit comments

Comments
 (0)