diff --git a/src/chocolatey.resources/helpers/functions/Get-FtpFile.ps1 b/src/chocolatey.resources/helpers/functions/Get-FtpFile.ps1 index e934023130..454309b91d 100644 --- a/src/chocolatey.resources/helpers/functions/Get-FtpFile.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-FtpFile.ps1 @@ -26,7 +26,7 @@ FileName location specified. This is a low-level function and not recommended for use in package scripts. It is recommended you call `Get-ChocolateyWebFile` instead. -Starting in 0.9.10, will automatically call Set-PowerShellExitCode to +Starting in 0.9.10, will automatically call Set-PowerShellExitCode to set the package exit code to 404 if the resource is not found. .INPUTS @@ -155,12 +155,13 @@ param( $total += $count $totalFormatted = Format-FileSize $total if($goal -gt 0) { - Write-Progress "Downloading $url to $fileName" "Saving $totalFormatted of $goalFormatted ($total/$goal)" -id 0 -percentComplete (($total/$goal)*100) + $percentComplete = [Math]::Truncate(($total/$goal)*100) + Write-Progress "Downloading $url to $fileName" "Saving $totalFormatted of $goalFormatted ($total/$goal)" -id 0 -percentComplete $percentComplete } else { Write-Progress "Downloading $url to $fileName" "Saving $total bytes..." -id 0 -Completed } - if ($total -eq $goal) { - Write-Progress "Completed download of $url." "Completed a total of $total bytes of $fileName" -id 0 -Completed + if ($total -eq $goal -and $count -eq 0) { + Write-Progress "Completed download of $url." "Completed a total of $total bytes of $fileName" -id 0 -Completed -PercentComplete 100 } } } while ($count -ne 0) diff --git a/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 b/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 index ea31e0e6fa..93a685f548 100644 --- a/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-WebFile.ps1 @@ -278,11 +278,12 @@ param( $total += $count $totalFormatted = Format-FileSize $total if($goal -gt 0 -and ++$iterLoop%10 -eq 0) { - Write-Progress "Downloading $url to $fileName" "Saving $totalFormatted of $goalFormatted ($total/$goal)" -id 0 -percentComplete (($total/$goal)*100) + $percentComplete = [Math]::Truncate(($total/$goal)*100) + Write-Progress "Downloading $url to $fileName" "Saving $totalFormatted of $goalFormatted ($total/$goal)" -id 0 -percentComplete $percentComplete } - if ($total -eq $goal) { - Write-Progress "Completed download of $url." "Completed download of $fileName ($goalFormatted)." -id 0 -Completed + if ($total -eq $goal -and $count -eq 0) { + Write-Progress "Completed download of $url." "Completed download of $fileName ($goalFormatted)." -id 0 -Completed -PercentComplete 100 } } } while ($count -gt 0) diff --git a/src/chocolatey/infrastructure/powershell/PoshHostUserInterface.cs b/src/chocolatey/infrastructure/powershell/PoshHostUserInterface.cs index 0dc7fbd8de..44e3a1e430 100644 --- a/src/chocolatey/infrastructure/powershell/PoshHostUserInterface.cs +++ b/src/chocolatey/infrastructure/powershell/PoshHostUserInterface.cs @@ -118,11 +118,10 @@ public override void WriteDebugLine(string message) } private bool hasLoggedStartProgress = false; - private bool hasLoggedFinalProgress = false; public override void WriteProgress(long sourceId, ProgressRecord record) { if (record.PercentComplete == -1) return; - if (hasLoggedFinalProgress) return; + if (!hasLoggedStartProgress) { hasLoggedStartProgress = true; @@ -130,14 +129,7 @@ public override void WriteProgress(long sourceId, ProgressRecord record) } // http://stackoverflow.com/a/888569/18475 - Console.Write("\rProgress: {0}% - {1}".format_with(record.PercentComplete.to_string(), record.StatusDescription.PadRight(50, ' '))); - - if (record.PercentComplete == 100 && !hasLoggedFinalProgress) - { - hasLoggedFinalProgress = true; - //this.Log().Info(""); - //this.Log().Info(record.StatusDescription.Replace("Saving","Finished downloading. Saved")); - } + Console.Write("\rProgress: {0}% - {1}".format_with(record.PercentComplete.to_string(), record.StatusDescription).PadRight(Console.WindowWidth)); } public override void WriteVerboseLine(string message)