mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(FileAccess*): Change the way home dir root is found, remove the excludeTrashbinMounts param of getDistinctMounts
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
parent
a2aeec0f4b
commit
cb221c8211
3 changed files with 4 additions and 46 deletions
|
|
@ -158,7 +158,7 @@ class FileAccess implements IFileAccess {
|
|||
$files->closeCursor();
|
||||
}
|
||||
|
||||
public function getDistinctMounts(array $mountProviders = [], bool $excludeTrashbinMounts = true, bool $rewriteHomeDirectories = true): \Generator {
|
||||
public function getDistinctMounts(array $mountProviders = [], bool $rewriteHomeDirectories = true): \Generator {
|
||||
$qb = $this->connection->getQueryBuilder();
|
||||
$qb->selectDistinct(['root_id', 'storage_id', 'mount_provider_class'])
|
||||
->from('mounts');
|
||||
|
|
@ -188,11 +188,7 @@ class FileAccess implements IFileAccess {
|
|||
->from('filecache')
|
||||
->where($qb->expr()->eq('storage', $qb->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($rootId, IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($qb->expr()->eq('name', $qb->createNamedParameter('files')));
|
||||
if ($excludeTrashbinMounts === true) {
|
||||
$qb->andWhere($qb->expr()->notLike('path', $qb->createNamedParameter('files_trashbin/%')))
|
||||
->andWhere($qb->expr()->notLike('path', $qb->createNamedParameter('__groupfolders/trash/%')));
|
||||
}
|
||||
->andWhere($qb->expr()->eq('path', $qb->createNamedParameter('files')));
|
||||
/** @var array|false $root */
|
||||
$root = $qb->executeQuery()->fetch();
|
||||
if ($root !== false) {
|
||||
|
|
|
|||
|
|
@ -100,16 +100,15 @@ interface IFileAccess {
|
|||
|
||||
/**
|
||||
* Retrieves a list of all distinct mounts.
|
||||
* Allows filtering by specific mount providers and excluding certain mount points.
|
||||
* Allows filtering by specific mount providers.
|
||||
* Optionally rewrites home directory root paths to avoid cache and trashbin.
|
||||
*
|
||||
* @param list<string> $mountProviders An array of mount provider class names to filter. If empty, all providers will be included.
|
||||
* @param bool $excludeTrashbinMounts Whether to include mounts that mount a directory in a user's trashbin.
|
||||
* @param bool $rewriteHomeDirectories Whether to rewrite the root path IDs for home directories to only include user files.
|
||||
* @return \Generator<array{storage_id: int, root_id: int, overridden_root: int}> A generator yielding mount configurations as an array containing 'storage_id', 'root_id', and 'override_root'.
|
||||
* @throws \OCP\DB\Exception
|
||||
*
|
||||
* @since 32.0.0
|
||||
*/
|
||||
public function getDistinctMounts(array $mountProviders = [], bool $excludeTrashbinMounts = true, bool $rewriteHomeDirectories = true): \Generator;
|
||||
public function getDistinctMounts(array $mountProviders = [], bool $rewriteHomeDirectories = true): \Generator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,16 +62,6 @@ class FileAccessTest extends TestCase {
|
|||
])
|
||||
->executeStatement();
|
||||
|
||||
$queryBuilder->insert('mounts')
|
||||
->values([
|
||||
'storage_id' => $queryBuilder->createNamedParameter(2, IQueryBuilder::PARAM_INT),
|
||||
'root_id' => $queryBuilder->createNamedParameter(20, IQueryBuilder::PARAM_INT),
|
||||
'mount_provider_class' => $queryBuilder->createNamedParameter('TestProviderClass2'),
|
||||
'mount_point' => $queryBuilder->createNamedParameter('/foobar/files_trashbin/test'),
|
||||
'user_id' => $queryBuilder->createNamedParameter('test'),
|
||||
])
|
||||
->executeStatement();
|
||||
|
||||
$queryBuilder->insert('mounts')
|
||||
->values([
|
||||
'storage_id' => $queryBuilder->createNamedParameter(3, IQueryBuilder::PARAM_INT),
|
||||
|
|
@ -125,33 +115,6 @@ class FileAccessTest extends TestCase {
|
|||
], $result[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that getDistinctMounts excludes certain mount points
|
||||
*/
|
||||
public function testGetDistinctMountsWithExclusionFilter(): void {
|
||||
$result = iterator_to_array($this->fileAccess->getDistinctMounts([], false));
|
||||
|
||||
$this->assertCount(3, $result);
|
||||
|
||||
$this->assertEquals([
|
||||
'storage_id' => 1,
|
||||
'root_id' => 10,
|
||||
'overridden_root' => 10,
|
||||
], $result[0]);
|
||||
|
||||
$this->assertEquals([
|
||||
'storage_id' => 2,
|
||||
'root_id' => 20,
|
||||
'overridden_root' => 20,
|
||||
], $result[1]);
|
||||
|
||||
$this->assertEquals([
|
||||
'storage_id' => 3,
|
||||
'root_id' => 30,
|
||||
'overridden_root' => 30,
|
||||
], $result[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that getDistinctMounts rewrites home directory paths
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue