Skip to content

Commit 17f8aa7

Browse files
authored
Merge pull request #33067 from nextcloud/trashbin-skip-size-cache
use size from cache to determine whether to skip the trashbin
2 parents 36a336b + 9188fad commit 17f8aa7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

apps/files_trashbin/lib/Trashbin.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,15 @@ public static function move2trash($file_path, $ownerOnly = false) {
255255
}
256256

257257
$ownerView = new View('/' . $owner);
258+
258259
// file has been deleted in between
259-
if (is_null($ownerPath) || $ownerPath === '' || !$ownerView->file_exists('/files/' . $ownerPath)) {
260+
if (is_null($ownerPath) || $ownerPath === '') {
261+
return true;
262+
}
263+
264+
$sourceInfo = $ownerView->getFileInfo('/files/' . $ownerPath);
265+
266+
if ($sourceInfo === false) {
260267
return true;
261268
}
262269

@@ -297,9 +304,8 @@ public static function move2trash($file_path, $ownerOnly = false) {
297304
}
298305
}
299306

300-
/** @var \OC\Files\Storage\Storage $sourceStorage */
301-
[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
302-
307+
$sourceStorage = $sourceInfo->getStorage();
308+
$sourceInternalPath = $sourceInfo->getInternalPath();
303309

304310
if ($trashStorage->file_exists($trashInternalPath)) {
305311
$trashStorage->unlink($trashInternalPath);
@@ -309,7 +315,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
309315
$systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1');
310316
$userTrashbinSize = (int)$config->getUserValue($owner, 'files_trashbin', 'trashbin_size', '-1');
311317
$configuredTrashbinSize = ($userTrashbinSize < 0) ? $systemTrashbinSize : $userTrashbinSize;
312-
if ($configuredTrashbinSize >= 0 && $sourceStorage->filesize($sourceInternalPath) >= $configuredTrashbinSize) {
318+
if ($configuredTrashbinSize >= 0 && $sourceInfo->getSize() >= $configuredTrashbinSize) {
313319
return false;
314320
}
315321

0 commit comments

Comments
 (0)