Skip to content

Commit 06e36dd

Browse files
committed
Only start progress bar if any queue items
1 parent 9ac342c commit 06e36dd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Commands/core/QueueCommands.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ public function run(string $name, $options = ['time-limit' => self::REQ, 'items-
7474
$queue->garbageCollection();
7575
}
7676

77-
$this->io()->progressStart($items_limit ?: $queue->numberOfItems());
77+
$max = $items_limit ?: $queue->numberOfItems();
78+
if ($max > 0) {
79+
$this->io()->progressStart($max);
80+
}
7881

7982
while ((!$time_limit || $remaining > 0) && (!$items_limit || $count < $items_limit) && ($item = $queue->claimItem($lease_time))) {
8083
try {
@@ -112,7 +115,9 @@ public function run(string $name, $options = ['time-limit' => self::REQ, 'items-
112115
$remaining = $end - time();
113116
}
114117
$elapsed = microtime(true) - $start;
115-
$this->io()->progressFinish();
118+
if ($max > 0) {
119+
$this->io()->progressFinish();
120+
}
116121
$this->logger()->success(dt('Processed @count items from the @name queue in @elapsed sec.', ['@count' => $count, '@name' => $name, '@elapsed' => round($elapsed, 2)]));
117122
}
118123

0 commit comments

Comments
 (0)