Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions functions/microwin/Force-CleanupMountDirectory.ps1
Comment thread
Real-MullaC marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ function Force-CleanupMountDirectory {
$null = reg query $hiveName 2>$null
if ($LASTEXITCODE -eq 0) {
# Registry hive is loaded, try to unload it with retries
$attempts = 0
$maxAttempts = 10
do {
$attempts++
while ($true) {
reg unload $hiveName 2>$null
if ($LASTEXITCODE -eq 0) {
break
}
Start-Sleep -Milliseconds 100
} until ($attempts -ge $maxAttempts)
}
}
} catch {
# Hive not loaded or error checking - continue
Expand Down
2 changes: 1 addition & 1 deletion functions/microwin/Invoke-WPFMicroWinGetIsoRunspace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ function Invoke-WPFMicroWinGetIsoRunspace {
$sync.form.Dispatcher.Invoke([action]{
$sync.MicrowinWindowsFlavors.SelectedIndex = $_.ImageIndex - 1
})
break # Exit the loop since we found the Pro edition
break
}
Comment thread
Real-MullaC marked this conversation as resolved.
# Allow UI updates during this loop
$sync.form.Dispatcher.Invoke([action]{
Expand Down
19 changes: 10 additions & 9 deletions functions/private/Copy-Files.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,30 @@ function Copy-Files {
foreach ($file in $files) {
$status = "Copying file {0} of {1}: {2}" -f $counter, $files.Count, $file.Name
Write-Progress -Activity "Copy disc image files" -Status $status -PercentComplete ($counter++/$files.count*100)
$restpath = $file.FullName -Replace $path, ''
$restpath = $file.FullName -Replace [regex]::Escape($path), ''

if ($file.PSIsContainer -eq $true) {
Write-Debug "Creating $($destination + $restpath)"
New-Item ($destination+$restpath) -Force:$force -Type Directory -ErrorAction SilentlyContinue
$targetPath = Join-Path $destination $restpath
Write-Debug "Creating $targetPath"
New-Item $targetPath -Force:$force -Type Directory -ErrorAction SilentlyContinue
} else {
Write-Debug "Copy from $($file.FullName) to $($destination+$restpath)"
$targetPath = Join-Path $destination $restpath
Write-Debug "Copy from $($file.FullName) to $targetPath"
try {
Copy-Item $file.FullName ($destination+$restpath) -ErrorAction Stop -Force:$force

Copy-Item $file.FullName $targetPath -ErrorAction Stop -Force:$force

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

# Force garbage collection to release file handles
$copiedFile = $null
} catch {
Write-Debug "Failed to copy $($file.FullName): $($_.Exception.Message)"
# Try alternative method if standard copy fails
try {
[System.IO.File]::Copy($file.FullName, ($destination+$restpath), $force)
[System.IO.File]::Copy($file.FullName, $targetPath, $force)
# Remove ReadOnly attribute using attrib for consistency
& attrib -R ($destination+$restpath) 2>$null
& attrib -R ($destination\$restpath) 2>$null
Comment thread
CodingWonders marked this conversation as resolved.
Outdated
} catch {
Write-Debug "Alternative copy method also failed: $($_.Exception.Message)"
}
Expand Down
Loading