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
4 changes: 4 additions & 0 deletions apps/files_external/tests/Service/DBConfigServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ protected function setUp(): void {
parent::setUp();
$this->connection = Server::get(IDBConnection::class);
$this->dbConfig = new DBConfigService($this->connection, Server::get(ICrypto::class));
// Remove any mounts left by a previously failed test run
foreach ($this->dbConfig->getAllMounts() as $mount) {
$this->dbConfig->removeMount($mount['mount_id']);
}
}

protected function tearDown(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public function clean(): void {
$this->removeMount($id);
}
}

public function cleanAll(): void {
foreach ($this->getAllMounts() as $mount) {
$this->removeMount($mount['mount_id']);
}
$this->mountIds = [];
}
}

#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
Expand All @@ -65,6 +72,7 @@ abstract class StoragesServiceTestCase extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
$this->dbConfig = new CleaningDBConfig(Server::get(IDBConnection::class), Server::get(ICrypto::class));
$this->dbConfig->cleanAll(); // Remove any mounts left by previous test runs
self::$hookCalls = [];
$config = Server::get(IConfig::class);
$this->dataDir = $config->getSystemValue(
Expand Down
5 changes: 5 additions & 0 deletions apps/files_sharing/tests/Repair/CleanupShareTargetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class CleanupShareTargetTest extends TestCase {
protected function setUp(): void {
parent::setUp();
$this->cleanupShareTarget = Server::get(CleanupShareTarget::class);
// Ensure all test users' home folders are in the filecache before any share
// operations, because tearDown wipes filecache and getShareById JOINs on it.
foreach ([self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER3] as $user) {
$this->rootFolder->getUserFolder($user)->getDirectoryListing();
}
}

private function createUserShare(string $by, string $target = self::TEST_FOLDER_NAME): IShare {
Expand Down
8 changes: 5 additions & 3 deletions lib/private/Files/Storage/Wrapper/Quota.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ public function fopen(string $path, string $mode) {
}

$source = $this->getWrapperStorage()->fopen($path, $mode);
if ($source && (is_int($free) || is_float($free)) && $free >= 0 && $mode !== 'r' && $mode !== 'rb') {
// only apply quota for files, not metadata, trash or others
if ($this->shouldApplyQuota($path)) {
if ($source && $mode !== 'r' && $mode !== 'rb' && $this->shouldApplyQuota($path)) {
if ((is_int($free) || is_float($free)) && $free >= 0) {
return \OC\Files\Stream\Quota::wrap($source, $free);
} elseif ($free === FileInfo::SPACE_NOT_COMPUTED) {
// Used space is unknown; apply full quota as a conservative ceiling
return \OC\Files\Stream\Quota::wrap($source, $this->getQuota());
}
}

Expand Down
45 changes: 25 additions & 20 deletions tests/lib/Files/Cache/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,26 +801,31 @@ public function testExtended(): void {
$entries = $this->cache->getFolderContents('');
$this->assertCount(4, $entries);

$this->assertEquals('foo1', $entries[0]->getName());
$this->assertEquals('foo2', $entries[1]->getName());
$this->assertEquals('foo3', $entries[2]->getName());
$this->assertEquals('foo4', $entries[3]->getName());

$this->assertEquals(20, $entries[0]->getCreationTime());
$this->assertEquals(0, $entries[0]->getUploadTime());
$this->assertEquals(null, $entries[0]->getMetadataEtag());

$this->assertEquals(0, $entries[1]->getCreationTime());
$this->assertEquals(30, $entries[1]->getUploadTime());
$this->assertEquals(null, $entries[1]->getMetadataEtag());

$this->assertEquals(0, $entries[2]->getCreationTime());
$this->assertEquals(0, $entries[2]->getUploadTime());
$this->assertEquals('foo', $entries[2]->getMetadataEtag());

$this->assertEquals(0, $entries[3]->getCreationTime());
$this->assertEquals(0, $entries[3]->getUploadTime());
$this->assertEquals(null, $entries[3]->getMetadataEtag());
// getFolderContentsById has no ORDER BY — index by name to avoid order-dependent assertions
$byName = [];
foreach ($entries as $entry) {
$byName[$entry->getName()] = $entry;
}
$this->assertArrayHasKey('foo1', $byName);
$this->assertArrayHasKey('foo2', $byName);
$this->assertArrayHasKey('foo3', $byName);
$this->assertArrayHasKey('foo4', $byName);

$this->assertEquals(20, $byName['foo1']->getCreationTime());
$this->assertEquals(0, $byName['foo1']->getUploadTime());
$this->assertEquals(null, $byName['foo1']->getMetadataEtag());

$this->assertEquals(0, $byName['foo2']->getCreationTime());
$this->assertEquals(30, $byName['foo2']->getUploadTime());
$this->assertEquals(null, $byName['foo2']->getMetadataEtag());

$this->assertEquals(0, $byName['foo3']->getCreationTime());
$this->assertEquals(0, $byName['foo3']->getUploadTime());
$this->assertEquals('foo', $byName['foo3']->getMetadataEtag());

$this->assertEquals(0, $byName['foo4']->getCreationTime());
$this->assertEquals(0, $byName['foo4']->getUploadTime());
$this->assertEquals(null, $byName['foo4']->getMetadataEtag());

$this->cache->update($id1, ['upload_time' => 25]);

Expand Down
Loading