diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-13 11:22:19 +0100 |
---|---|---|
committer | Backportbot <backportbot-noreply@rullzer.com> | 2019-11-13 14:09:53 +0000 |
commit | e899e4957cccc868ff7aa4e0894e382d88b0d18f (patch) | |
tree | 59af31a27c9856900cfb6fd3aad73865af421249 /apps/files | |
parent | 2c8554e0906730d205f06d5f29f2ae9e249c3e37 (diff) | |
download | nextcloud-server-e899e4957cccc868ff7aa4e0894e382d88b0d18f.tar.gz nextcloud-server-e899e4957cccc868ff7aa4e0894e382d88b0d18f.zip |
Check quota before transfer ownership
Fixes #15664
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/lib/Command/TransferOwnership.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/files/lib/Command/TransferOwnership.php b/apps/files/lib/Command/TransferOwnership.php index f417898f217..a77a02a4947 100644 --- a/apps/files/lib/Command/TransferOwnership.php +++ b/apps/files/lib/Command/TransferOwnership.php @@ -32,6 +32,7 @@ use OC\Files\Filesystem; use OC\Files\View; use OCP\Files\FileInfo; use OCP\Files\IHomeStorage; +use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountManager; use OCP\IUser; use OCP\IUserManager; @@ -76,7 +77,10 @@ class TransferOwnership extends Command { /** @var string */ private $finalTarget; - public function __construct(IUserManager $userManager, IManager $shareManager, IMountManager $mountManager) { + public function __construct(IUserManager $userManager, + IManager $shareManager, + IMountManager $mountManager, + IRootFolder $rootFolder) { $this->userManager = $userManager; $this->shareManager = $shareManager; $this->mountManager = $mountManager; @@ -174,6 +178,15 @@ class TransferOwnership extends Command { */ protected function analyse(OutputInterface $output) { $view = new View(); + + $output->writeln('Validating quota'); + $size = $view->getFileInfo($this->sourcePath, false)->getSize(false); + $freeSpace = $view->free_space($this->destinationUser . '/files/'); + if ($size > $freeSpace) { + $output->writeln('<error>Target user does not have enough free space available</error>'); + throw new \Exception('Execution terminated'); + } + $output->writeln("Analysing files of $this->sourceUser ..."); $progress = new ProgressBar($output); $progress->start(); @@ -207,7 +220,6 @@ class TransferOwnership extends Command { } throw new \Exception('Execution terminated.'); } - } /** |