Skip to content

Commit d744c04

Browse files
authored
Merge pull request #16534 from nextcloud/trash-copy-free-space
dont try to copy trash items to user if the user has not enough free space
2 parents 0e19e55 + 9bf8ee7 commit d744c04

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/files_trashbin/lib/Trashbin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ private static function copyFilesToUser($sourcePath, $owner, $targetPath, $user,
189189

190190
$target = $user . '/files_trashbin/files/' . $targetFilename . '.d' . $timestamp;
191191
$source = $owner . '/files_trashbin/files/' . $sourceFilename . '.d' . $timestamp;
192-
self::copy_recursive($source, $target, $view);
192+
$free = $view->free_space($target);
193+
$isUnknownOrUnlimitedFreeSpace = $free < 0;
194+
$isEnoughFreeSpaceLeft = $view->filesize($source) < $free;
195+
if ($isUnknownOrUnlimitedFreeSpace || $isEnoughFreeSpaceLeft) {
196+
self::copy_recursive($source, $target, $view);
197+
}
193198

194199

195200
if ($view->file_exists($target)) {

0 commit comments

Comments
 (0)