From 38521a0a2effe3aded20927572aa578e6631c3c0 Mon Sep 17 00:00:00 2001 From: Daniele Corsini Date: Thu, 20 Aug 2020 18:07:30 +0200 Subject: [PATCH] Fix waitForTaskToFinish --- src/PveClientBase.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PveClientBase.php b/src/PveClientBase.php index ebc691e..f6a6a3e 100644 --- a/src/PveClientBase.php +++ b/src/PveClientBase.php @@ -378,7 +378,7 @@ public function getLastResult() { * @param string $task Task identifier * @param int $wait Millisecond wait next check * @param int $timeOut Millisecond timeout - * @return int 0 Success + * @return bool */ public function waitForTaskToFinish($node, $task, $wait = 500, $timeOut = 10000) { $isRunning = true; @@ -390,14 +390,14 @@ public function waitForTaskToFinish($node, $task, $wait = 500, $timeOut = 10000) } $timeStart = time(); $waitTime = time(); - while ($isRunning && ($timeStart - time()) < $timeOut) { + while ($isRunning && (time() - $timeStart) < $timeOut) { if ((time() - $waitTime) >= $wait) { $waitTime = time(); $isRunning = taskIsRunning($node, $task); } } - return $timeStart - time() < $timeOut ? 0 : 1; + return (time() - $timeStart ) < $timeOut; } /** @@ -405,7 +405,7 @@ public function waitForTaskToFinish($node, $task, $wait = 500, $timeOut = 10000) * @param string $task Task identifier * @param int $wait Millisecond wait next check * @param int $timeOut Millisecond timeout - * @return int 0 Success + * @return bool */ function waitForTaskToFinish1($task, $wait = 500, $timeOut = 10000) { return waitForTaskToFinish(split(':', $task)[1], $task, $wait, $timeOut);