From 63cef77e2925c104e41c34317751ff2d14a355d4 Mon Sep 17 00:00:00 2001 From: Robin Kluth Date: Thu, 30 Mar 2023 17:09:49 +0200 Subject: [PATCH] Make wget percentage detection more robust --- plugins/dynamix.plugin.manager/scripts/plugin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/dynamix.plugin.manager/scripts/plugin b/plugins/dynamix.plugin.manager/scripts/plugin index 4c9523435..3ec462533 100755 --- a/plugins/dynamix.plugin.manager/scripts/plugin +++ b/plugins/dynamix.plugin.manager/scripts/plugin @@ -238,9 +238,9 @@ function download($url, $name, &$error, $write=true) { if ($file = popen("wget --compression=auto --no-cache --progress=dot --retry-connrefused --prefer-family=IPv4 --timeout=10 --tries=$tries --waitretry=$tries -O $name $url 2>&1", 'r')) { if ($write) write("plugin: downloading: $plg ...\r"); $level = -1; - while (($line = fgets($file)) !== false) { - if (preg_match('/\d+%/', $line, $matches)) { - $percentage = substr($matches[0],0,-1); + while (($line = fgets($file)) !== false) { + if (preg_match('/ \d+% /', $line, $matches)) { + $percentage = substr(trim($matches[0]),0,-1); if ($percentage > $level) { if ($write) write("plugin: downloading: $plg ... $percentage%\r"); $level = $percentage;