MDL-70536 cli: Fixed cli progress bar when 100% more than once

This commit is contained in:
Brendan Heywood 2021-02-06 15:50:02 +11:00
parent 67fb670cc6
commit a87ddbd685
2 changed files with 2 additions and 6 deletions

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify

View File

@ -4939,9 +4939,6 @@ class core_renderer_cli extends core_renderer {
$ascii .= '<cursor:up>';
$ascii .= sprintf("[$bar] %3.1f%% %-22s\n", $percent, $estimate);
$ascii .= sprintf("%-80s\n", $msg);
if ($percent == 100) {
$ascii .= "\n";
}
return cli_ansi_format($ascii);
}
@ -4950,12 +4947,12 @@ class core_renderer_cli extends core_renderer {
// which can only ever go forwards.
$done = round($percent * $size * 0.01);
$delta = max(0, $done - $this->progressmaximums[$id]);
$this->progressmaximums[$id] += $delta;
$ascii .= str_repeat('#', $delta);
if ($percent >= 100) {
if ($percent >= 100 && $delta > 0) {
$ascii .= sprintf("] %3.1f%%\n$msg\n", $percent);
}
$this->progressmaximums[$id] += $delta;
return $ascii;
}