|
32 | 32 | use OC\Files\View; |
33 | 33 | use OCP\Files\FileInfo; |
34 | 34 | use OCP\Files\IHomeStorage; |
| 35 | +use OCP\Files\IRootFolder; |
35 | 36 | use OCP\Files\Mount\IMountManager; |
36 | 37 | use OCP\IUser; |
37 | 38 | use OCP\IUserManager; |
@@ -76,7 +77,10 @@ class TransferOwnership extends Command { |
76 | 77 | /** @var string */ |
77 | 78 | private $finalTarget; |
78 | 79 |
|
79 | | - public function __construct(IUserManager $userManager, IManager $shareManager, IMountManager $mountManager) { |
| 80 | + public function __construct(IUserManager $userManager, |
| 81 | + IManager $shareManager, |
| 82 | + IMountManager $mountManager, |
| 83 | + IRootFolder $rootFolder) { |
80 | 84 | $this->userManager = $userManager; |
81 | 85 | $this->shareManager = $shareManager; |
82 | 86 | $this->mountManager = $mountManager; |
@@ -174,6 +178,15 @@ private function walkFiles(View $view, $path, \Closure $callBack) { |
174 | 178 | */ |
175 | 179 | protected function analyse(OutputInterface $output) { |
176 | 180 | $view = new View(); |
| 181 | + |
| 182 | + $output->writeln('Validating quota'); |
| 183 | + $size = $view->getFileInfo($this->sourcePath, false)->getSize(false); |
| 184 | + $freeSpace = $view->free_space($this->destinationUser . '/files/'); |
| 185 | + if ($size > $freeSpace) { |
| 186 | + $output->writeln('<error>Target user does not have enough free space available</error>'); |
| 187 | + throw new \Exception('Execution terminated'); |
| 188 | + } |
| 189 | + |
177 | 190 | $output->writeln("Analysing files of $this->sourceUser ..."); |
178 | 191 | $progress = new ProgressBar($output); |
179 | 192 | $progress->start(); |
@@ -207,7 +220,6 @@ function (FileInfo $fileInfo) use ($progress, $self) { |
207 | 220 | } |
208 | 221 | throw new \Exception('Execution terminated.'); |
209 | 222 | } |
210 | | - |
211 | 223 | } |
212 | 224 |
|
213 | 225 | /** |
|
0 commit comments