From 522663b9f0833ee031f6ab52efea0cf444b6d288 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 3 Feb 2026 16:20:41 +0100 Subject: [PATCH] fix: partial external storage config matching non-child mounts Signed-off-by: Robin Appelman --- .../lib/Service/DBConfigService.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php index f20d22254f6..d6135ff88cc 100644 --- a/apps/files_external/lib/Service/DBConfigService.php +++ b/apps/files_external/lib/Service/DBConfigService.php @@ -122,27 +122,30 @@ class DBConfigService { $path = str_replace('/' . $userId . '/files', '', $path); $path = rtrim($path, '/'); if ($path === '') { - $path = '/'; + $nonChildPath = '/'; + } else { + $nonChildPath = $path; } + $builder = $this->getSelectQueryBuilder(); + $pathFilter = $forChildren + ? $builder->expr()->like('m.mount_point', $builder->createNamedParameter($this->connection->escapeLikeParameter($path) . '/_%', IQueryBuilder::PARAM_STR)) + : $builder->expr()->eq('m.mount_point', $builder->createNamedParameter($nonChildPath, IQueryBuilder::PARAM_STR)); $builder->where($builder->expr()->orX( $builder->expr()->andX( // global mounts $builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_GLOBAL, IQueryBuilder::PARAM_INT)), $builder->expr()->isNull('a.value'), - $forChildren ? $builder->expr()->like('m.mount_point', $builder->createNamedParameter($this->connection->escapeLikeParameter($path) . '_%', IQueryBuilder::PARAM_STR)) - : $builder->expr()->eq('m.mount_point', $builder->createNamedParameter($path, IQueryBuilder::PARAM_STR)), + $pathFilter, ), $builder->expr()->andX( // mounts for user $builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_USER, IQueryBuilder::PARAM_INT)), $builder->expr()->eq('a.value', $builder->createNamedParameter($userId)), - $forChildren ? $builder->expr()->like('m.mount_point', $builder->createNamedParameter($this->connection->escapeLikeParameter($path) . '_%', IQueryBuilder::PARAM_STR)) - : $builder->expr()->eq('m.mount_point', $builder->createNamedParameter($path, IQueryBuilder::PARAM_STR)), + $pathFilter, ), $builder->expr()->andX( // mounts for group $builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_GROUP, IQueryBuilder::PARAM_INT)), $builder->expr()->in('a.value', $builder->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY)), - $forChildren ? $builder->expr()->like('m.mount_point', $builder->createNamedParameter($this->connection->escapeLikeParameter($path) . '_%', IQueryBuilder::PARAM_STR)) - : $builder->expr()->eq('m.mount_point', $builder->createNamedParameter($path, IQueryBuilder::PARAM_STR)), + $pathFilter, ), )); @@ -160,7 +163,7 @@ class DBConfigService { ->where($builder->expr()->andX( // global mounts $builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_GLOBAL, IQueryBuilder::PARAM_INT)), $builder->expr()->isNull('a.value'), - ), ); + )); return $this->getMountsFromQuery($query); }