From 9b6ec3378fae13bee10ca1701fe62292925f2d5c Mon Sep 17 00:00:00 2001 From: Anyon Date: Tue, 15 Dec 2020 18:13:28 +0800 Subject: [PATCH] ComposerUpdate --- vendor/composer/installed.json | 8 ++++---- vendor/services.php | 2 +- vendor/zoujingli/think-library/src/Command.php | 7 ++++--- vendor/zoujingli/think-library/src/Queue.php | 7 ++++--- .../zoujingli/think-library/src/command/Queue.php | 4 ++-- .../think-library/src/service/QueueService.php | 15 ++++++++++----- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index da95fb5c4..84e251635 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -937,12 +937,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "6095c8e362118fd00d00f924a7ec342859e88104" + "reference": "7fc5a459d6d05cb905b1e0c604a50e9a36795ecb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/6095c8e362118fd00d00f924a7ec342859e88104", - "reference": "6095c8e362118fd00d00f924a7ec342859e88104", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/7fc5a459d6d05cb905b1e0c604a50e9a36795ecb", + "reference": "7fc5a459d6d05cb905b1e0c604a50e9a36795ecb", "shasum": "", "mirrors": [ { @@ -959,7 +959,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2020-12-10T08:26:28+00:00", + "time": "2020-12-15T10:00:46+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index d03f55092..dec0927ff 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/src/Command.php b/vendor/zoujingli/think-library/src/Command.php index cb3c89d7f..56d614b22 100644 --- a/vendor/zoujingli/think-library/src/Command.php +++ b/vendor/zoujingli/think-library/src/Command.php @@ -70,13 +70,14 @@ abstract class Command extends ThinkCommand /** * 设置进度消息并继续执行 * @param null|string $message 进度消息 - * @param null|integer $progress 进度数值 + * @param null|float $progress 进度数值 + * @param integer $backline 回退行数 * @return static */ - protected function setQueueProgress(?string $message = null, $progress = null) + protected function setQueueProgress(?string $message = null, $progress = null, $backline = 0): Command { if (defined('WorkQueueCode')) { - $this->queue->progress(2, $message, $progress); + $this->queue->progress(2, $message, $progress, $backline); } elseif (is_string($message)) { $this->output->writeln($message); } diff --git a/vendor/zoujingli/think-library/src/Queue.php b/vendor/zoujingli/think-library/src/Queue.php index 47e26d709..51848a985 100644 --- a/vendor/zoujingli/think-library/src/Queue.php +++ b/vendor/zoujingli/think-library/src/Queue.php @@ -77,12 +77,13 @@ abstract class Queue /** * 设置任务的进度 * @param null|string $message 进度消息 - * @param null|integer $progress 进度数值 + * @param null|float $progress 进度数值 + * @param integer $backline 回退行数 * @return Queue */ - protected function setQueueProgress(?string $message = null, $progress = null): Queue + protected function setQueueProgress(?string $message = null, $progress = null, $backline = 0): Queue { - $this->queue->progress(2, $message, $progress); + $this->queue->progress(2, $message, $progress, $backline); return $this; } diff --git a/vendor/zoujingli/think-library/src/command/Queue.php b/vendor/zoujingli/think-library/src/command/Queue.php index d64ab2403..0a82e2386 100644 --- a/vendor/zoujingli/think-library/src/command/Queue.php +++ b/vendor/zoujingli/think-library/src/command/Queue.php @@ -297,7 +297,7 @@ class Queue extends Command $this->updateQueue(3, $this->app->console->call(array_shift($attr), $attr)->fetch(), false); } } - } catch (\Exception|\Error|\Throwable $exception) { + } catch (\Exception | \Error | \Throwable $exception) { $code = $exception->getCode(); if (intval($code) !== 3) $code = 4; $this->updateQueue($code, $exception->getMessage()); @@ -333,7 +333,7 @@ class Queue extends Command if (isset($this->queue->record['loops_time']) && $this->queue->record['loops_time'] > 0) { try { $this->queue->initialize($this->code)->reset($this->queue->record['loops_time']); - } catch (\Exception|\Error|\Throwable $exception) { + } catch (\Exception | \Error | \Throwable $exception) { $this->app->log->error("Queue {$this->queue->record['code']} Loops Failed. {$exception->getMessage()}"); } } diff --git a/vendor/zoujingli/think-library/src/service/QueueService.php b/vendor/zoujingli/think-library/src/service/QueueService.php index 7ba86d872..4bbd45d99 100644 --- a/vendor/zoujingli/think-library/src/service/QueueService.php +++ b/vendor/zoujingli/think-library/src/service/QueueService.php @@ -154,9 +154,10 @@ class QueueService extends Service * @param null|integer $status 任务状态 * @param null|string $message 进度消息 * @param null|float $progress 进度数值 + * @param integer $backline 回退信息行 * @return array */ - public function progress(?int $status = null, ?string $message = null, $progress = null): array + public function progress(?int $status = null, ?string $message = null, $progress = null, $backline = 0): array { $ckey = "queue_{$this->code}_progress"; if (is_numeric($status) && intval($status) === 3) { @@ -171,8 +172,11 @@ class QueueService extends Service $data = $this->app->cache->get($ckey, [ 'code' => $this->code, 'status' => $status, 'message' => $message, 'progress' => $progress, 'history' => [], ]); - } catch (\Exception|\Error $exception) { - return $this->progress($status, $message, $progress); + } catch (\Exception | \Error $exception) { + return $this->progress($status, $message, $progress, $backline); + } + while (count($data['history']) > 0 && $backline > 0) { + [--$backline, array_pop($data['history'])]; } if (is_numeric($status)) $data['status'] = intval($status); if (is_numeric($progress)) $progress = str_pad(sprintf("%.2f", $progress), 6, '0', STR_PAD_LEFT); @@ -201,14 +205,15 @@ class QueueService extends Service * @param integer $total 记录总和 * @param integer $used 当前记录 * @param string $message 文字描述 + * @param integer $backline 回退行数 */ - public function message(int $total, int $used, string $message = ''): void + public function message(int $total, int $used, string $message = '', $backline = 0): void { $total = $total < 1 ? 1 : $total; $prefix = str_pad("{$used}", strlen("{$total}"), '0', STR_PAD_LEFT); $message = "[{$prefix}/{$total}] {$message}"; if (defined('WorkQueueCode')) { - $this->progress(2, $message, sprintf("%.2f", $used / $total * 100)); + $this->progress(2, $message, sprintf("%.2f", $used / $total * 100), $backline); } else { echo $message . PHP_EOL; }