From a5d643a820e1be54199b06125ec9fc4088afeb87 Mon Sep 17 00:00:00 2001 From: Michael Pietsch Date: Fri, 22 Nov 2019 11:56:17 +0100 Subject: [PATCH] Sanity check when transfering ownership of files If the result is not checked it is possible that the file transfer failed or is denied (eg. quota exceeded). If this happens it should not be tried to change the shares to the (not existend) target path. If the check is not present the transfer ownership currently may show `Share with id points at deleted file, skipping` for each share the original user had --- apps/files/lib/Command/TransferOwnership.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/files/lib/Command/TransferOwnership.php b/apps/files/lib/Command/TransferOwnership.php index a77a02a49475f..4279e7674a7de 100644 --- a/apps/files/lib/Command/TransferOwnership.php +++ b/apps/files/lib/Command/TransferOwnership.php @@ -155,7 +155,10 @@ protected function execute(InputInterface $input, OutputInterface $output) { $this->collectUsersShares($output); // transfer the files - $this->transfer($output); + if($this->transfer($output) === false) { + $output->writeln('File transfer failed'); + return 1; + } // restore the shares $this->restoreShares($output); @@ -259,7 +262,9 @@ protected function transfer(OutputInterface $output) { $view->mkdir($this->finalTarget); $this->finalTarget = $this->finalTarget . '/' . basename($this->sourcePath); } - $view->rename($this->sourcePath, $this->finalTarget); + if ($view->rename($this->sourcePath, $this->finalTarget) === false) { + return false; + } if (!is_dir("$this->sourceUser/files")) { // because the files folder is moved away we need to recreate it $view->mkdir("$this->sourceUser/files");