aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Command/Get.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/lib/Command/Get.php')
-rw-r--r--apps/files/lib/Command/Get.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/apps/files/lib/Command/Get.php b/apps/files/lib/Command/Get.php
index 29edefa1cfb..7bdb4cb59ee 100644
--- a/apps/files/lib/Command/Get.php
+++ b/apps/files/lib/Command/Get.php
@@ -43,8 +43,8 @@ class Get extends Command {
$this
->setName('files:get')
->setDescription('Get the contents of a file')
- ->addArgument('file', InputArgument::REQUIRED, "File id or path")
- ->addArgument('output', InputArgument::OPTIONAL, "Target file to output to, defaults to STDOUT");
+ ->addArgument('file', InputArgument::REQUIRED, "Source file id or Nextcloud path")
+ ->addArgument('output', InputArgument::OPTIONAL, "Target local file to output to, defaults to STDOUT");
}
public function execute(InputInterface $input, OutputInterface $output): int {
@@ -68,7 +68,16 @@ class Get extends Command {
return 1;
}
$source = $node->fopen('r');
- $target = (!$outputName || $outputName === '-') ? STDOUT : fopen($outputName, 'w');
+ if (!$source) {
+ $output->writeln("<error>Failed to open $fileInput for reading</error>");
+ return 1;
+ }
+ $target = ($outputName === null || $outputName === '-') ? STDOUT : fopen($outputName, 'w');
+ if (!$target) {
+ $output->writeln("<error>Failed to open $outputName for reading</error>");
+ return 1;
+ }
+
stream_copy_to_stream($source, $target);
return 0;
} else {