From 468f8bd0e2aa08a45980fd13333bdcdbab9303ad Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 24 Sep 2020 11:36:59 +0800 Subject: [PATCH] ComposerUpdate --- vendor/composer/installed.json | 12 +++---- .../zoujingli/think-library/src/Library.php | 2 +- .../think-library/src/command/Database.php | 4 +-- .../think-library/src/command/Install.php | 32 +++++++++++-------- .../think-library/src/command/Queue.php | 6 ++-- vendor/zoujingli/think-library/src/common.php | 15 +++++++++ 6 files changed, 46 insertions(+), 25 deletions(-) diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 5549b2518..3aedd9e13 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -958,17 +958,17 @@ }, { "name": "zoujingli/think-library", - "version": "v6.0.12", - "version_normalized": "6.0.12.0", + "version": "v6.0.13", + "version_normalized": "6.0.13.0", "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "a25e52f4f8af59ee55e33d00fff42ee919abba46" + "reference": "4f492966b363a613ec7e89af47db0c59fe322350" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a25e52f4f8af59ee55e33d00fff42ee919abba46", - "reference": "a25e52f4f8af59ee55e33d00fff42ee919abba46", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/4f492966b363a613ec7e89af47db0c59fe322350", + "reference": "4f492966b363a613ec7e89af47db0c59fe322350", "shasum": "", "mirrors": [ { @@ -985,7 +985,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2020-09-24T02:44:19+00:00", + "time": "2020-09-24T03:26:07+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/zoujingli/think-library/src/Library.php b/vendor/zoujingli/think-library/src/Library.php index 515c01b93..e17f349bc 100644 --- a/vendor/zoujingli/think-library/src/Library.php +++ b/vendor/zoujingli/think-library/src/Library.php @@ -41,7 +41,7 @@ class Library extends Service /** * 扩展库版本号 */ - const VERSION = '6.0.12'; + const VERSION = '6.0.13'; /** * 启动服务 diff --git a/vendor/zoujingli/think-library/src/command/Database.php b/vendor/zoujingli/think-library/src/command/Database.php index e21aa0026..b0a95fcb8 100644 --- a/vendor/zoujingli/think-library/src/command/Database.php +++ b/vendor/zoujingli/think-library/src/command/Database.php @@ -64,7 +64,7 @@ class Database extends Command [$total, $used] = [count($tables = $this->getTables()), 0]; $this->setQueueProgress("总共需要修复 {$total} 张数据表", 0); foreach ($tables as $table) { - $stridx = str_pad(++$used, strlen("{$total}"), '0', STR_PAD_LEFT) . "/{$total}"; + $stridx = progress_prefix($total, ++$used); $this->setQueueProgress("[{$stridx}] 正在修复数据表 {$table}", $used / $total * 100); $this->app->db->query("REPAIR TABLE `{$table}`"); } @@ -83,7 +83,7 @@ class Database extends Command [$total, $used] = [count($tables = $this->getTables()), 0]; $this->setQueueProgress("总共需要优化 {$total} 张数据表", 0); foreach ($tables as $table) { - $stridx = str_pad(++$used, strlen("{$total}"), '0', STR_PAD_LEFT) . "/{$total}"; + $stridx = progress_prefix($total, ++$used); $this->setQueueProgress("[{$stridx}] 正在优化数据表 {$table}", $used / $total * 100); $this->app->db->query("OPTIMIZE TABLE `{$table}`"); } diff --git a/vendor/zoujingli/think-library/src/command/Install.php b/vendor/zoujingli/think-library/src/command/Install.php index 07cad7cba..9f5d5e83e 100644 --- a/vendor/zoujingli/think-library/src/command/Install.php +++ b/vendor/zoujingli/think-library/src/command/Install.php @@ -114,20 +114,26 @@ class Install extends Command } } - protected function installFile() + private function installFile() { - $data = ModuleService::instance()->grenerateDifference($this->rules, $this->ignore); - if (empty($data)) $this->output->writeln('No need to update the file if the file comparison is consistent'); - else foreach ($data as $file) { - [$state, $mode, $name] = ModuleService::instance()->updateFileByDownload($file); - if ($state) { - if ($mode === 'add') $this->output->writeln("--- {$name} add successfully"); - if ($mode === 'mod') $this->output->writeln("--- {$name} update successfully"); - if ($mode === 'del') $this->output->writeln("--- {$name} delete successfully"); - } else { - if ($mode === 'add') $this->output->writeln("--- {$name} add failed"); - if ($mode === 'mod') $this->output->writeln("--- {$name} update failed"); - if ($mode === 'del') $this->output->writeln("--- {$name} delete failed"); + $module = ModuleService::instance(); + $data = $module->grenerateDifference($this->rules, $this->ignore); + if (empty($data)) { + $this->output->writeln('No need to update the file if the file comparison is consistent'); + } else { + [$total, $used] = [count($data), 0]; + foreach ($data as $file) { + $prefix = progress_prefix($total, ++$used); + [$state, $mode, $name] = $module->updateFileByDownload($file); + if ($state) { + if ($mode === 'add') $this->output->writeln("[{$prefix}] --- {$name} add successfully"); + if ($mode === 'mod') $this->output->writeln("[{$prefix}] --- {$name} update successfully"); + if ($mode === 'del') $this->output->writeln("[{$prefix}] --- {$name} delete successfully"); + } else { + if ($mode === 'add') $this->output->writeln("[{$prefix}] --- {$name} add failed"); + if ($mode === 'mod') $this->output->writeln("[{$prefix}] --- {$name} update failed"); + if ($mode === 'del') $this->output->writeln("[{$prefix}] --- {$name} delete failed"); + } } } } diff --git a/vendor/zoujingli/think-library/src/command/Queue.php b/vendor/zoujingli/think-library/src/command/Queue.php index b9baabe12..0f1e3f99f 100644 --- a/vendor/zoujingli/think-library/src/command/Queue.php +++ b/vendor/zoujingli/think-library/src/command/Queue.php @@ -189,12 +189,12 @@ class Queue extends Command $this->app->db->name($this->table)->whereOr([$map1, $map2])->chunk(100, function (Collection $result) use ($total, &$loops, &$timeout) { foreach ($result->toArray() as $item) { $item['loops_time'] > 0 ? $loops++ : $timeout++; - $prefix = str_pad($timeout + $loops, strlen("{$total}"), 0, STR_PAD_LEFT); + $prefix = progress_prefix($total, $timeout + $loops); if ($item['loops_time'] > 0) { - $this->setQueueProgress("[{$prefix}/{$total}] 正在重置任务 {$item['code']} 为运行", ($timeout + $loops) * 100 / $total); + $this->setQueueProgress("[{$prefix}] 正在重置任务 {$item['code']} 为运行", ($timeout + $loops) * 100 / $total); [$status, $message] = [1, intval($item['status']) === 4 ? '任务执行失败,已自动重置任务!' : '任务执行超时,已自动重置任务!']; } else { - $this->setQueueProgress("[{$prefix}/{$total}] 正在标记任务 {$item['code']} 为超时", ($timeout + $loops) * 100 / $total); + $this->setQueueProgress("[{$prefix}] 正在标记任务 {$item['code']} 为超时", ($timeout + $loops) * 100 / $total); [$status, $message] = [4, '任务执行超时,已自动标识为失败!']; } $this->app->db->name($this->table)->where(['id' => $item['id']])->update(['status' => $status, 'exec_desc' => $message]); diff --git a/vendor/zoujingli/think-library/src/common.php b/vendor/zoujingli/think-library/src/common.php index aea747500..c393f3a99 100644 --- a/vendor/zoujingli/think-library/src/common.php +++ b/vendor/zoujingli/think-library/src/common.php @@ -141,6 +141,7 @@ if (!function_exists('sysoplog')) { return SystemService::instance()->setOplog($action, $content); } } + if (!function_exists('encode')) { /** * 加密 UTF8 字符串 @@ -281,4 +282,18 @@ if (!function_exists('down_file')) { $result = Storage::down($source, $force, $expire); return $result['url'] ?? $source; } +} + +if (!function_exists('progress_prefix')) { + /** + * 生成进度前缀文字 + * @param integer $total + * @param integer $used + * @param string $char + * @return string + */ + function progress_prefix(int $total, int $used, string $char = '0'): string + { + return str_pad("{$used}", strlen("{$total}"), $char, STR_PAD_LEFT) . "/{$total}"; + } } \ No newline at end of file