diff options
Diffstat (limited to 'apps/files/lib/Command/Object/Get.php')
-rw-r--r-- | apps/files/lib/Command/Object/Get.php | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/apps/files/lib/Command/Object/Get.php b/apps/files/lib/Command/Object/Get.php index c07a64b20e2..cad1f3d98ac 100644 --- a/apps/files/lib/Command/Object/Get.php +++ b/apps/files/lib/Command/Object/Get.php @@ -31,10 +31,9 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Get extends Command { - private ObjectUtil $objectUtils; - - public function __construct(ObjectUtil $objectUtils) { - $this->objectUtils = $objectUtils; + public function __construct( + private ObjectUtil $objectUtils, + ) { parent::__construct(); } @@ -52,29 +51,29 @@ class Get extends Command { $outputName = $input->getArgument('output'); $objectStore = $this->objectUtils->getObjectStore($input->getOption("bucket"), $output); if (!$objectStore) { - return 1; + return self::FAILURE; } if (!$objectStore->objectExists($object)) { $output->writeln("<error>Object $object does not exist</error>"); - return 1; - } else { - try { - $source = $objectStore->readObject($object); - } catch (\Exception $e) { - $msg = $e->getMessage(); - $output->writeln("<error>Failed to read $object from object store: $msg</error>"); - return 1; - } - $target = $outputName === '-' ? STDOUT : fopen($outputName, 'w'); - if (!$target) { - $output->writeln("<error>Failed to open $outputName for writing</error>"); - return 1; - } + return self::FAILURE; + } - stream_copy_to_stream($source, $target); - return 0; + try { + $source = $objectStore->readObject($object); + } catch (\Exception $e) { + $msg = $e->getMessage(); + $output->writeln("<error>Failed to read $object from object store: $msg</error>"); + return self::FAILURE; } + $target = $outputName === '-' ? STDOUT : fopen($outputName, 'w'); + if (!$target) { + $output->writeln("<error>Failed to open $outputName for writing</error>"); + return self::FAILURE; + } + + stream_copy_to_stream($source, $target); + return self::SUCCESS; } } |