Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
845b780
feat(IFileAccess#getByAncestorInStorage): Add new method to retrieve …
marcelklehr Mar 31, 2025
3eef614
feat(IFileAccess#getMounts): Add new method to retrieve all distinct …
marcelklehr Mar 31, 2025
611d83a
fix: Fix psalm issues
marcelklehr Mar 31, 2025
d8c6f8d
fix(FileAccess): Address review comments
marcelklehr Apr 1, 2025
5689af5
fix(FileAccess): Run cs:fix
marcelklehr Apr 1, 2025
d67c877
fix(FileAccess): Add tests
marcelklehr Apr 1, 2025
10cc430
fix(FileAccess#getByAncestorInStorage): Use a subquery to fix tests
marcelklehr Apr 3, 2025
34b3f75
fix(FileAccess#getDistinctMounts): Order results deterministically
marcelklehr Apr 4, 2025
3941622
fix(FileAccessTest): Make sure path_hash is not NULL
marcelklehr Apr 4, 2025
895160a
fix(FileAccessTest): Do not use LIMIT in subquery
marcelklehr Apr 4, 2025
26f6013
fix(FileAccessTest): Make it work on sharded instance
marcelklehr Apr 4, 2025
131125b
fix(FileAccessTest): Adress review comments
marcelklehr Apr 10, 2025
7e98698
fix(FileAccess*): Adress review comments
julien-nc May 28, 2025
28dc4a2
fix(FileAccess): exclude trashbin nodes on the oc_filecache query, th…
julien-nc Jun 2, 2025
a2aeec0
fix(FileAccess*): Adress review comments
julien-nc Jun 3, 2025
cb221c8
fix(FileAccess*): Change the way home dir root is found, remove the e…
julien-nc Jun 3, 2025
3a96f8e
fix(FileAccess*): fix tests
julien-nc Jun 3, 2025
43be97d
fix(FileAccess): Use one param for rewriting home dirs and excluding …
marcelklehr Jul 7, 2025
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
Prev Previous commit
Next Next commit
fix(FileAccess#getByAncestorInStorage): Use a subquery to fix tests
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jul 15, 2025
commit 10cc43041bb6a0fd7470ec13e7e48f871aa1895e
16 changes: 12 additions & 4 deletions lib/private/Files/Cache/FileAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,16 @@ public function getByAncestorInStorage(int $storageId, int $rootId, int $lastFil

if (!$endToEndEncrypted) {
// End to end encrypted files are descendants of a folder with encrypted=1
$qb->leftJoin('f', 'filecache', 'p', $qb->expr()->eq('f.parent', 'p.fileid'));
$qb->andWhere($qb->expr()->eq('p.encrypted', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)));
// Use a subquery to check the `encrypted` status of the parent folder
$subQuery = $this->getQuery()->select('p.encrypted')
->from('filecache', 'p')
->andWhere($qb->expr()->eq('p.fileid', 'f.parent'))
->setMaxResults(1)
->getSQL();

$qb->andWhere(
$qb->expr()->eq($qb->createFunction(sprintf('(%s)', $subQuery)), $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))
);
}

if (!$serverSideEncrypted) {
Expand All @@ -151,8 +159,8 @@ public function getByAncestorInStorage(int $storageId, int $rootId, int $lastFil
if ($maxResults !== 0) {
$qb->setMaxResults($maxResults);
}
$files = $qb->orderBy('f.fileid', 'ASC')
->executeQuery();
$qb->orderBy('f.fileid', 'ASC');
$files = $qb->executeQuery();

while (
/** @var array */
Expand Down
9 changes: 4 additions & 5 deletions tests/lib/Files/Cache/FileAccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private function setUpTestDatabaseForGetByAncestorInStorage(): void {
$queryBuilder->insert('filecache')
->values([
'fileid' => 5,
'parent' => 0,
'parent' => 1,
'path' => $queryBuilder->createNamedParameter('files/serversideencrypted'),
'path_hash' => $queryBuilder->createNamedParameter(md5('files/serversideencrypted')),
'storage' => $queryBuilder->createNamedParameter(1),
Expand Down Expand Up @@ -350,10 +350,9 @@ public function testGetByAncestorInStorageWithoutEndToEndEncrypted(): void {

$result = iterator_to_array($generator);

var_dump($result);

$this->assertCount(1, $result);
$this->assertEquals('files/serversideencrypted', $result[0]->getPath());
$this->assertCount(3, $result);
$paths = array_map(fn(CacheEntry $entry) => $entry->getPath(), $result);
$this->assertEquals(['files/documents', 'files/photos', 'files/serversideencrypted'], $paths);
}

/**
Expand Down