Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions apps/files/lib/Command/TransferOwnership.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -174,6 +178,15 @@ private function walkFiles(View $view, $path, \Closure $callBack) {
*/
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();
Expand Down Expand Up @@ -207,7 +220,6 @@ function (FileInfo $fileInfo) use ($progress, $self) {
}
throw new \Exception('Execution terminated.');
}

}

/**
Expand Down