From 9188fad1908045aa88537ad389942e474f96bc6d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 29 Jun 2022 17:53:22 +0200 Subject: [PATCH] use size from cache to determine whether to skip the trashbin this way large folders also get skipped Signed-off-by: Robin Appelman --- apps/files_trashbin/lib/Trashbin.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 72072a2588c..d449a136016 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -255,8 +255,15 @@ class Trashbin { } $ownerView = new View('/' . $owner); + // file has been deleted in between - if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) { + if (is_null($ownerPath) || $ownerPath === '') { + return true; + } + + $sourceInfo = $ownerView->getFileInfo('/files/' . $ownerPath); + + if ($sourceInfo === false) { return true; } @@ -297,9 +304,8 @@ class Trashbin { } } - /** @var \OC\Files\Storage\Storage $sourceStorage */ - [$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath); - + $sourceStorage = $sourceInfo->getStorage(); + $sourceInternalPath = $sourceInfo->getInternalPath(); if ($trashStorage->file_exists($trashInternalPath)) { $trashStorage->unlink($trashInternalPath); @@ -309,7 +315,7 @@ class Trashbin { $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) { + if ($configuredTrashbinSize >= 0 && $sourceInfo->getSize() >= $configuredTrashbinSize) { return false; } -- 2.39.5