Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(files_trashbin): Fix size propagation when moving file to trash
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Sep 9, 2025
commit b36af651fd3546d5787c772e4ab28dea06324f97
3 changes: 2 additions & 1 deletion apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,9 @@ public static function move2trash($file_path, $ownerOnly = false) {
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) {
Expand Down
22 changes: 22 additions & 0 deletions apps/files_trashbin/tests/TrashbinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,28 @@ public function testRestoreFileIntoReadOnlySourceFolder(): void {
}
}

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
Expand Down
Loading