mirror of
https://github.com/unraid/webgui.git
synced 2026-01-07 01:59:52 -06:00
Small rsync ETA fix and improved regex
- tac --before prevents line concatenation, when status file randomly lacks trailing \n - Add leading space (^ ) to regex which guarantess matching the progress line
This commit is contained in:
@@ -139,7 +139,9 @@ function parse_rsync_progress($status, $action_label) {
|
||||
// transfer of single file finished (ETA changes temporarily to elapsed time):
|
||||
// " 37.93G 4% 53.80MB/s 0:11:12 (xfr#32, to-chk=554/596)"
|
||||
// note: we do not loop with PHP as there could be a huge amount of progress lines
|
||||
$progress_line = trim(exec("tac $status | grep -m1 -E '[0-9]+%.*[0-9]+:[0-9]+:[0-9]+' | tr -s ' ' || echo ''"));
|
||||
// note: leading space in regex ensures we only match progress lines, not filenames
|
||||
// note: tac --before prevents line concatenation when $status lacks trailing \n
|
||||
$progress_line = trim(exec("tac --before $status | grep -m1 -E '^ .*[0-9]+%.*[0-9]+:[0-9]+:[0-9]+' | tr -s ' ' || echo ''"));
|
||||
if ($progress_line) {
|
||||
$parts = explode(' ', $progress_line);
|
||||
if (count($parts) >= 4) {
|
||||
@@ -165,7 +167,7 @@ function parse_rsync_progress($status, $action_label) {
|
||||
// obtain filename line like:
|
||||
// "/mnt/disk6/images/image.jpg"
|
||||
// note: -v is used to obtain the opposite of the progress line regex and to filter out empty lines
|
||||
$file_line = exec("tac $status | grep -m1 -v -E '(^\$|[0-9]+%.*[0-9]+:[0-9]+:[0-9]+)' | tr -s ' ' || echo ''");
|
||||
$file_line = exec("tail -n5 $status | grep -v -E '(^\$|^ .*[0-9]+%.*[0-9]+:[0-9]+:[0-9]+)' | tail -1 | tr -s ' ' || echo ''");
|
||||
if ($file_line) {
|
||||
$text[0] .= htmlspecialchars(mb_strimhalf($file_line, 70, '...'), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user