From 059e6459a83ad278f2dd6f681d81cd3c979e5253 Mon Sep 17 00:00:00 2001 From: Anyon Date: Fri, 27 Mar 2020 10:19:58 +0800 Subject: [PATCH] =?UTF-8?q?ComposerUpdate&=E4=BC=98=E5=8C=96=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/api/Upload.php | 19 +++++++++++++------ composer.lock | 8 ++++---- vendor/composer/installed.json | 8 ++++---- vendor/services.php | 2 +- .../src/command/queue/WorkQueue.php | 2 +- .../src/service/QueueService.php | 3 ++- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/admin/controller/api/Upload.php b/app/admin/controller/api/Upload.php index c0d75e87f..9c7fa84e3 100644 --- a/app/admin/controller/api/Upload.php +++ b/app/admin/controller/api/Upload.php @@ -57,9 +57,8 @@ class Upload extends Controller */ public function state() { - $this->name = input('name', null); - $this->safe = boolval(input('safe')); - $data = ['uptype' => $this->getType(), 'xkey' => input('xkey')]; + list($this->name, $this->safe) = [input('name', null), boolval(input('safe'))]; + $data = ['uptype' => $this->getType(), 'xkey' => input('xkey'), 'safe' => $this->safe]; if ($info = Storage::instance($data['uptype'])->info($data['xkey'], $this->safe, $this->name)) { $data['url'] = $info['url']; $this->success('文件已经上传', $data, 200); @@ -78,8 +77,7 @@ class Upload extends Controller $data['OSSAccessKeyId'] = $token['keyid']; $data['server'] = AliossStorage::instance()->upload(); } - $data['safe'] = intval($this->safe); - $this->success('获取上传参数', $data, 404); + $this->success('获取授权参数', $data, 404); } /** @@ -106,7 +104,16 @@ class Upload extends Controller } list($this->safe, $this->uptype, $this->name) = [boolval(input('safe')), $this->getType(), input('xkey')]; if (empty($this->name)) $this->name = Storage::name($file->getPathname(), $this->extension, '', 'md5_file'); - $info = Storage::instance($this->uptype)->set($this->name, file_get_contents($file->getRealPath()), $this->safe, $file->getOriginalName()); + if ($this->uptype === 'local') { + $local = LocalStorage::instance(); + $realpath = dirname($realname = $local->path($this->name, $this->safe)); + file_exists($realpath) && is_dir($realpath) || mkdir($realpath, 0755, true); + @move_uploaded_file($file->getPathname(), $realname); + $info = $local->info($this->name, $this->safe, $file->getOriginalName()); + } else { + $bina = file_get_contents($file->getRealPath()); + $info = Storage::instance($this->uptype)->set($this->name, $bina, $this->safe, $file->getOriginalName()); + } if (is_array($info) && isset($info['url'])) { return json(['uploaded' => true, 'filename' => $this->name, 'url' => $this->safe ? $this->name : $info['url']]); } else { diff --git a/composer.lock b/composer.lock index 1fe9a27af..ef1a8c277 100644 --- a/composer.lock +++ b/composer.lock @@ -909,12 +909,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e" + "reference": "233e269155871ca9ef6b818536687d5862acef5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e", - "reference": "ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/233e269155871ca9ef6b818536687d5862acef5b", + "reference": "233e269155871ca9ef6b818536687d5862acef5b", "shasum": "", "mirrors": [ { @@ -958,7 +958,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2020-03-25T02:06:11+00:00" + "time": "2020-03-26T10:28:21+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index eb3e9baff..db39bfe1a 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -935,12 +935,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e" + "reference": "233e269155871ca9ef6b818536687d5862acef5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e", - "reference": "ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/233e269155871ca9ef6b818536687d5862acef5b", + "reference": "233e269155871ca9ef6b818536687d5862acef5b", "shasum": "", "mirrors": [ { @@ -956,7 +956,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2020-03-25T02:06:11+00:00", + "time": "2020-03-26T10:28:21+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index f574442d4..498deba7b 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/command/queue/WorkQueue.php b/vendor/zoujingli/think-library/src/command/queue/WorkQueue.php index e01b78a41..09433ee7e 100644 --- a/vendor/zoujingli/think-library/src/command/queue/WorkQueue.php +++ b/vendor/zoujingli/think-library/src/command/queue/WorkQueue.php @@ -138,7 +138,7 @@ class WorkQueue extends Queue if (isset($this->queue['loops_time']) && $this->queue['loops_time'] > 0) { try { $this->qService->initialize($this->code)->reset($this->queue['loops_time']); - } catch (\Exception $exception) { + } catch (\Exception|\Error $exception) { $this->app->log->error("Queue {$this->queue['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 d3eafafb3..fb94df0ee 100644 --- a/vendor/zoujingli/think-library/src/service/QueueService.php +++ b/vendor/zoujingli/think-library/src/service/QueueService.php @@ -139,8 +139,9 @@ class QueueService extends Service if (empty($rscript) && ($queue = $this->app->db->name('SystemQueue')->where($map)->find())) { throw new \think\admin\Exception(lang('think_library_queue_exist'), 0, $queue['code']); } + $this->code = CodeExtend::uniqidDate(16, 'Q'); $this->app->db->name('SystemQueue')->strict(false)->failException(true)->insert([ - 'code' => $this->code = CodeExtend::uniqidDate(16, 'Q'), + 'code' => $this->code, 'title' => $title, 'command' => $command, 'attempts' => '0',