mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 18:50:47 -04:00
fix(files_trashbin): Fix size propagation when moving file to trash
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
bb8c800e5b
commit
3e5b43c37a
2 changed files with 24 additions and 1 deletions
|
|
@ -287,8 +287,9 @@ class Trashbin {
|
|||
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 (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
|
||||
|
|
|
|||
|
|
@ -653,6 +653,28 @@ class TrashbinTest extends \Test\TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public function testTrashSizePropagation(): void {
|
||||
$view = new \OC\Files\View('/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin/files');
|
||||
|
||||
$userFolder = \OCP\Server::get(\OCP\Files\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
|
||||
|
|
|
|||
Loading…
Reference in a new issue