From 62630512fd76d8e84312ae406f927845eba6194b Mon Sep 17 00:00:00 2001 From: overtrue Date: Thu, 4 Mar 2021 13:14:30 +0800 Subject: [PATCH] Fixed #16 --- src/CosAdapter.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/CosAdapter.php b/src/CosAdapter.php index 8c8125f..c2aeaf5 100644 --- a/src/CosAdapter.php +++ b/src/CosAdapter.php @@ -400,10 +400,18 @@ protected function normalizeFileInfo(array $content) */ protected function listObjects($directory = '', $recursive = false) { - return $this->getBucketClient()->getObjects([ + $result = $this->getBucketClient()->getObjects([ 'prefix' => ('' === (string) $directory) ? '' : ($directory.'/'), 'delimiter' => $recursive ? '' : '/', ])['ListBucketResult']; + + $result['Contents'] = $result['Contents'] ?? []; + + if (($key = \key($result['Contents'])) !== 0) { + $result['Contents'] = \is_null($key) ? [] : [$result['Contents']]; + } + + return $result; } /**