Skip to content

Commit 1f454ce

Browse files
provokateurinbackportbot[bot]
authored andcommitted
fix(files_trashbin): Fix size propagation when moving file to trash
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 8f3217b commit 1f454ce

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

apps/files_trashbin/lib/Trashbin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,9 @@ public static function move2trash($file_path, $ownerOnly = false) {
293293
try {
294294
$moveSuccessful = true;
295295

296+
$inCache = $sourceStorage->getCache()->inCache($sourceInternalPath);
296297
$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
297-
if ($sourceStorage->getCache()->inCache($sourceInternalPath)) {
298+
if ($inCache) {
298299
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
299300
}
300301
} catch (CopyRecursiveException $e) {

apps/files_trashbin/tests/TrashbinTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,28 @@ public function testRestoreFileIntoReadOnlySourceFolder(): void {
664664
}
665665
}
666666

667+
public function testTrashSizePropagation(): void {
668+
$view = new View('/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin/files');
669+
670+
$userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
671+
$file1 = $userFolder->newFile('foo.txt');
672+
$file1->putContent('1');
673+
674+
$this->assertTrue($userFolder->nodeExists('foo.txt'));
675+
$file1->delete();
676+
$this->assertFalse($userFolder->nodeExists('foo.txt'));
677+
$this->assertEquals(1, $view->getFileInfo('')->getSize());
678+
679+
$folder = $userFolder->newFolder('bar');
680+
$file2 = $folder->newFile('baz.txt');
681+
$file2->putContent('22');
682+
683+
$this->assertTrue($userFolder->nodeExists('bar'));
684+
$folder->delete();
685+
$this->assertFalse($userFolder->nodeExists('bar'));
686+
$this->assertEquals(3, $view->getFileInfo('')->getSize());
687+
}
688+
667689
/**
668690
* @param string $user
669691
* @param bool $create

0 commit comments

Comments
 (0)