Skip to content

Commit 0366f3e

Browse files
committed
Update
1 parent 46fdd82 commit 0366f3e

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

functions/microwin/Force-CleanupMountDirectory.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,13 @@ function Force-CleanupMountDirectory {
2828
$null = reg query $hiveName 2>$null
2929
if ($LASTEXITCODE -eq 0) {
3030
# Registry hive is loaded, try to unload it with retries
31-
$attempts = 0
32-
$maxAttempts = 10
33-
do {
34-
$attempts++
31+
while ($true) {
3532
reg unload $hiveName 2>$null
3633
if ($LASTEXITCODE -eq 0) {
3734
break
3835
}
3936
Start-Sleep -Milliseconds 100
40-
} until ($attempts -ge $maxAttempts)
37+
}
4138
}
4239
} catch {
4340
# Hive not loaded or error checking - continue

functions/microwin/Invoke-WPFMicroWinGetIsoRunspace.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ function Invoke-WPFMicroWinGetIsoRunspace {
426426
$sync.form.Dispatcher.Invoke([action]{
427427
$sync.MicrowinWindowsFlavors.SelectedIndex = $_.ImageIndex - 1
428428
})
429-
break # Exit the loop since we found the Pro edition
429+
break
430430
}
431431
# Allow UI updates during this loop
432432
$sync.form.Dispatcher.Invoke([action]{

functions/private/Copy-Files.ps1

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,30 @@ function Copy-Files {
3030
foreach ($file in $files) {
3131
$status = "Copying file {0} of {1}: {2}" -f $counter, $files.Count, $file.Name
3232
Write-Progress -Activity "Copy disc image files" -Status $status -PercentComplete ($counter++/$files.count*100)
33-
$restpath = $file.FullName -Replace $path, ''
33+
$restpath = $file.FullName -Replace [regex]::Escape($path), ''
3434

3535
if ($file.PSIsContainer -eq $true) {
36-
Write-Debug "Creating $($destination + $restpath)"
37-
New-Item ($destination+$restpath) -Force:$force -Type Directory -ErrorAction SilentlyContinue
36+
$targetPath = Join-Path $destination $restpath
37+
Write-Debug "Creating $targetPath"
38+
New-Item $targetPath -Force:$force -Type Directory -ErrorAction SilentlyContinue
3839
} else {
39-
Write-Debug "Copy from $($file.FullName) to $($destination+$restpath)"
40+
$targetPath = Join-Path $destination $restpath
41+
Write-Debug "Copy from $($file.FullName) to $targetPath"
4042
try {
41-
Copy-Item $file.FullName ($destination+$restpath) -ErrorAction Stop -Force:$force
42-
43+
Copy-Item $file.FullName $targetPath -ErrorAction Stop -Force:$force
4344

4445
# Remove ReadOnly attribute using attrib for consistency
45-
& attrib -R ($destination+$restpath) 2>$null
46+
& attrib -R $targetPath 2>$null
4647

4748
# Force garbage collection to release file handles
4849
$copiedFile = $null
4950
} catch {
5051
Write-Debug "Failed to copy $($file.FullName): $($_.Exception.Message)"
5152
# Try alternative method if standard copy fails
5253
try {
53-
[System.IO.File]::Copy($file.FullName, ($destination+$restpath), $force)
54+
[System.IO.File]::Copy($file.FullName, $targetPath, $force)
5455
# Remove ReadOnly attribute using attrib for consistency
55-
& attrib -R ($destination+$restpath) 2>$null
56+
& attrib -R ($destination\$restpath) 2>$null
5657
} catch {
5758
Write-Debug "Alternative copy method also failed: $($_.Exception.Message)"
5859
}

0 commit comments

Comments
 (0)