Merge pull request #54950 from nextcloud/fix/files_trashbin/size-propagation

This commit is contained in:
Kate 2025-09-09 15:36:32 +02:00 committed by GitHub
commit c0dc179c8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -297,8 +297,9 @@ class Trashbin implements IEventListener {
try {
$moveSuccessful = true;
$inCache = $sourceStorage->getCache()->inCache($sourceInternalPath);
$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
if ($sourceStorage->getCache()->inCache($sourceInternalPath)) {
if ($inCache) {
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
}
} catch (CopyRecursiveException $e) {

View file

@ -656,6 +656,28 @@ class TrashbinTest extends \Test\TestCase {
}
}
public function testTrashSizePropagation(): void {
$view = new View('/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin/files');
$userFolder = Server::get(IRootFolder::class)->getUserFolder(self::TEST_TRASHBIN_USER1);
$file1 = $userFolder->newFile('foo.txt');
$file1->putContent('1');
$this->assertTrue($userFolder->nodeExists('foo.txt'));
$file1->delete();
$this->assertFalse($userFolder->nodeExists('foo.txt'));
$this->assertEquals(1, $view->getFileInfo('')->getSize());
$folder = $userFolder->newFolder('bar');
$file2 = $folder->newFile('baz.txt');
$file2->putContent('22');
$this->assertTrue($userFolder->nodeExists('bar'));
$folder->delete();
$this->assertFalse($userFolder->nodeExists('bar'));
$this->assertEquals(3, $view->getFileInfo('')->getSize());
}
/**
* @param string $user
* @param bool $create