|
13 | 13 | use OC\Files\View; |
14 | 14 | use OCA\DAV\Connector\Sabre\FilesPlugin; |
15 | 15 | use OCA\Files_Trashbin\Trash\ITrashItem; |
| 16 | +use OCP\Files\IRootFolder; |
| 17 | +use OCP\Files\Mount\IMountManager; |
16 | 18 | use OCP\IPreview; |
17 | 19 | use Psr\Log\LoggerInterface; |
18 | 20 | use Sabre\DAV\INode; |
@@ -44,6 +46,8 @@ class TrashbinPlugin extends ServerPlugin { |
44 | 46 | public function __construct( |
45 | 47 | private readonly IPreview $previewManager, |
46 | 48 | private readonly View $view, |
| 49 | + private readonly IRootFolder $rootFolder, |
| 50 | + private readonly IMountManager $mountManager, |
47 | 51 | ) { |
48 | 52 | } |
49 | 53 |
|
@@ -175,7 +179,16 @@ public function beforeMove(string $sourcePath, string $destinationPath): bool { |
175 | 179 | return true; |
176 | 180 | } |
177 | 181 |
|
178 | | - $freeSpace = $this->view->free_space($destinationParentPath); |
| 182 | + $userFolder = $this->rootFolder->getUserFolder($fileInfo->getUser()->getUID()); |
| 183 | + $originalPath = $userFolder->getFullPath(dirname($fileInfo->getOriginalLocation())); |
| 184 | + |
| 185 | + // Since the parent folder might no longer exist, we don't try to get the parent node to check the free space |
| 186 | + // instead we resolve the mount where the restore would go to, and check that for the free space |
| 187 | + $originalMount = $this->mountManager->find($originalPath); |
| 188 | + if (!$originalMount) { |
| 189 | + throw new \Exception('no mount found when looking for restore path'); |
| 190 | + } |
| 191 | + $freeSpace = $originalMount->getStorage()->free_space($originalMount->getInternalPath($originalPath)); |
179 | 192 |
|
180 | 193 | if ( |
181 | 194 | $freeSpace === FileInfo::SPACE_NOT_COMPUTED |
|
0 commit comments