Skip to content

Commit

Permalink
Fix waitForTaskToFinish
Browse files Browse the repository at this point in the history
  • Loading branch information
franklupo committed Aug 20, 2020
1 parent 90881db commit 38521a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/PveClientBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -390,22 +390,22 @@ 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;
}

/**
* Wait for task to finish
* @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);
Expand Down

0 comments on commit 38521a0

Please sign in to comment.