Skip to content

Commit 91a7e65

Browse files
committed
fix: prevent restoring a file that's larger than the free space
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent e68d903 commit 91a7e65

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

apps/files_trashbin/lib/Trashbin.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use OCP\Files\IMimeTypeLoader;
3838
use OCP\Files\IRootFolder;
3939
use OCP\Files\Node;
40+
use OCP\Files\NotEnoughSpaceException;
4041
use OCP\Files\NotFoundException;
4142
use OCP\Files\NotPermittedException;
4243
use OCP\Files\Storage\ILockingStorage;
@@ -566,6 +567,13 @@ public static function restore($file, $filename, $timestamp) {
566567

567568
$sourceNode = self::getNodeForPath($user, $sourcePath);
568569
$targetNode = self::getNodeForPath($user, $targetPath, 'files');
570+
571+
$targetParent = $targetNode->getParent();
572+
573+
if ($targetParent->getFreeSpace() < $sourceNode->getSize(false)) {
574+
throw new NotEnoughSpaceException('Not enough free space in ' . $targetParent->getPath() . ' to restore ' . $sourceNode->getPath());
575+
}
576+
569577
$run = true;
570578
$event = new BeforeNodeRestoredEvent($sourceNode, $targetNode, $run);
571579
$dispatcher = Server::get(IEventDispatcher::class);

0 commit comments

Comments
 (0)