Skip to content
Open
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
14 changes: 14 additions & 0 deletions lib/Folder/FolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,20 @@ public function setFolderQuota(int $folderId, int $quota): void {
$query->executeStatement();

$this->eventDispatcher->dispatchTyped(new CriticalActionPerformedEvent('The quota for groupfolder with id %d was set to %d bytes', [$folderId, $quota]));

// Bump the root etag so desktop clients re-fetch quota-available-bytes on
// their next PROPFIND. Going through Cache::update() also emits the cache
// events notify_push relies on; no user session or mounted storage is needed.
try {
$folder = $this->getFolder($folderId);
if ($folder !== null) {
$storage = $this->folderStorageManager->getBaseStorageForFolder($folder->id, $folder->useSeparateStorage(), $folder);
$storage->getCache()->update($folder->rootId, ['etag' => uniqid()]);
}
} catch (\Exception $e) {
// Best effort: a failed invalidation must not fail the quota update
$this->logger->warning('Failed to invalidate group folder root etag after quota change', ['folderId' => $folderId, 'exception' => $e]);
}
}

/**
Expand Down
31 changes: 31 additions & 0 deletions tests/Folder/FolderManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,37 @@ public function testGetFolderPermissionsForUserMerge(): void {
$this->assertEquals(0, $permissions);
}

public function testSetFolderQuotaInvalidatesEtag(): void {
$this->config->expects($this->any())
->method('getSystemValueInt')
->with('groupfolders.quota.default', FileInfo::SPACE_UNLIMITED)
->willReturn(FileInfo::SPACE_UNLIMITED);

$folderId = $this->manager->createFolder('quota-etag-test');

$folderBefore = $this->manager->getFolder($folderId);
$this->assertNotNull($folderBefore);
$etagBefore = $folderBefore->rootCacheEntry->getEtag();

$this->manager->setFolderQuota($folderId, 1024 * 1024 * 1024);

$folderAfter = $this->manager->getFolder($folderId);
$this->assertNotNull($folderAfter);
$etagAfter = $folderAfter->rootCacheEntry->getEtag();

$this->assertNotEquals(
$etagBefore,
$etagAfter,
'Etag must change after quota update so desktop clients re-fetch quota-available-bytes via PROPFIND',
);

$this->assertSame(
1024 * 1024 * 1024,
$folderAfter->quota,
'Quota value must be persisted correctly',
);
}

public function testQuotaDefaultValue(): void {
$folderId1 = $this->manager->createFolder('foo');

Expand Down
Loading