mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 08:25:56 -04:00
Merge pull request #54971 from nextcloud/backport/54950/stable31
[stable31] fix(files_trashbin): Fix size propagation when moving file to trash
This commit is contained in:
commit
808cb1f72c
2 changed files with 26 additions and 1 deletions
|
|
@ -293,8 +293,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) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ use OCA\Files_Trashbin\Trashbin;
|
|||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\FileInfo;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IConfig;
|
||||
use OCP\Server;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
/**
|
||||
|
|
@ -664,6 +666,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
|
||||
|
|
|
|||
Loading…
Reference in a new issue