Skip to content

Commit

Permalink
MDL-70536 cli: Fixed cli progress bar when 100% more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed Feb 6, 2021
1 parent 67fb670 commit a87ddbd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
1 change: 0 additions & 1 deletion admin/cli/dashboard_reset.php
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 2 additions & 5 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4939,9 +4939,6 @@ public function render_progress_bar_update(string $id, float $percent, string $m
$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);
}

Expand All @@ -4950,12 +4947,12 @@ public function render_progress_bar_update(string $id, float $percent, string $m
// 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;
}

Expand Down

0 comments on commit a87ddbd

Please sign in to comment.