diff --git a/app/Console/Commands/OssCopy.php b/app/Console/Commands/OssCopy.php index 9414a082..18c89ade 100644 --- a/app/Console/Commands/OssCopy.php +++ b/app/Console/Commands/OssCopy.php @@ -85,23 +85,27 @@ class OssCopy extends Command { $data = []; foreach($attributes as $key) { - $item = $model->$key; - if (!$item) { - continue; - } - // 数组 - if (is_array($item)) { - $values = []; - foreach($item as $value) { - array_push($values, $this->copy($value)); + try { + $item = $model->$key; + if (!$item) { + continue; } - $data[$key] = $values; - } - // 富文本 - else if (preg_match('/^\<.+\>$/i', $item)) { - $data[$key] = $this->parseEditorImage($item); - } else { - $data[$key] = $this->copy($item); + // 数组 + if (is_array($item)) { + $values = []; + foreach($item as $value) { + array_push($values, $this->copy($value)); + } + $data[$key] = $values; + } + // 富文本 + else if (preg_match('/^\<.+\>$/i', $item)) { + $data[$key] = $this->parseEditorImage($item); + } else { + $data[$key] = $this->copy($item); + } + } catch (OssException $e) { + $this->error('key: ' . $key . ', value: ' . $item . ', id: ' . $model->id); } } if (count($data) > 0) { @@ -120,11 +124,7 @@ class OssCopy extends Command if (Str::startsWith($url, $baseUrl)) { $path = substr($url, strlen($baseUrl)); $bucket = 'jiqu-library'; - try { - $client->copyObject($oldBucket, $path, $bucket, $path); - } catch (OssException $e) { - $this->error('地址:' . $url); - } + $client->copyObject($oldBucket, $path, $bucket, $path); return $newUrl . $path; }