From 3c47aaa2b1cc7f6045784a12edbd36fa7925fe72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 23 Sep 2020 16:38:24 +0200 Subject: [PATCH] Delete files that exceed trashbin size immediately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/files_trashbin/lib/Trashbin.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 276cdf4e2d..b1e1d0600b 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -285,6 +285,14 @@ class Trashbin { $trashStorage->unlink($trashInternalPath); } + $config = \OC::$server->getConfig(); + $systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1'); + $userTrashbinSize = (int)$config->getUserValue($owner, 'files_trashbin', 'trashbin_size', '-1'); + $configuredTrashbinSize = ($userTrashbinSize < 0) ? $systemTrashbinSize : $userTrashbinSize; + if ($configuredTrashbinSize >= 0 && $sourceStorage->filesize($sourceInternalPath) >= $configuredTrashbinSize) { + return false; + } + $connection = \OC::$server->getDatabaseConnection(); $connection->beginTransaction(); $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);