aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2025-05-12 17:35:17 +0200
committerRobin Appelman <robin@icewind.nl>2025-05-16 21:37:29 +0200
commit66791c7263983c4d095f440d79d4cfba73b35ed3 (patch)
tree8b6a9eacadc45aebdd816a4dcb30fb4511a65f1c
parent4252648a0c60a70bd2fe87223a758d44ef082590 (diff)
downloadnextcloud-server-backport/51818/stable31.tar.gz
nextcloud-server-backport/51818/stable31.zip
feat: add mount id to info:storage(s)backport/51818/stable31
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--core/Command/Info/FileUtils.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/Command/Info/FileUtils.php b/core/Command/Info/FileUtils.php
index dcc275cb99e..a433b61b43c 100644
--- a/core/Command/Info/FileUtils.php
+++ b/core/Command/Info/FileUtils.php
@@ -28,7 +28,7 @@ use OCP\Util;
use Symfony\Component\Console\Output\OutputInterface;
/**
- * @psalm-type StorageInfo array{numeric_id: int, id: string, available: bool, last_checked: ?\DateTime, files: int}
+ * @psalm-type StorageInfo array{numeric_id: int, id: string, available: bool, last_checked: ?\DateTime, files: int, mount_id: ?int}
*/
class FileUtils {
public function __construct(
@@ -245,12 +245,13 @@ class FileUtils {
*/
public function getStorage(int $id): ?array {
$query = $this->connection->getQueryBuilder();
- $query->select('numeric_id', 'id', 'available', 'last_checked')
+ $query->select('numeric_id', 's.id', 'available', 'last_checked', 'mount_id')
->selectAlias($query->func()->count('fileid'), 'files')
->from('storages', 's')
->innerJoin('s', 'filecache', 'f', $query->expr()->eq('f.storage', 's.numeric_id'))
+ ->leftJoin('s', 'mounts', 'm', $query->expr()->eq('s.numeric_id', 'm.storage_id'))
->where($query->expr()->eq('s.numeric_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
- ->groupBy('s.numeric_id', 's.id', 's.available', 's.last_checked');
+ ->groupBy('s.numeric_id', 's.id', 's.available', 's.last_checked', 'mount_id');
$row = $query->executeQuery()->fetch();
if ($row) {
return [
@@ -259,6 +260,7 @@ class FileUtils {
'files' => $row['files'],
'available' => (bool)$row['available'],
'last_checked' => $row['last_checked'] ? new \DateTime('@' . $row['last_checked']) : null,
+ 'mount_id' => $row['mount_id'],
];
} else {
return null;
@@ -272,11 +274,12 @@ class FileUtils {
*/
public function listStorages(?int $limit): \Iterator {
$query = $this->connection->getQueryBuilder();
- $query->select('numeric_id', 'id', 'available', 'last_checked')
+ $query->select('numeric_id', 's.id', 'available', 'last_checked', 'mount_id')
->selectAlias($query->func()->count('fileid'), 'files')
->from('storages', 's')
->innerJoin('s', 'filecache', 'f', $query->expr()->eq('f.storage', 's.numeric_id'))
- ->groupBy('s.numeric_id', 's.id', 's.available', 's.last_checked')
+ ->leftJoin('s', 'mounts', 'm', $query->expr()->eq('s.numeric_id', 'm.storage_id'))
+ ->groupBy('s.numeric_id', 's.id', 's.available', 's.last_checked', 'mount_id')
->orderBy('files', 'DESC');
if ($limit !== null) {
$query->setMaxResults($limit);
@@ -289,6 +292,7 @@ class FileUtils {
'files' => $row['files'],
'available' => (bool)$row['available'],
'last_checked' => $row['last_checked'] ? new \DateTime('@' . $row['last_checked']) : null,
+ 'mount_id' => $row['mount_id'],
];
}
}
@@ -304,6 +308,7 @@ class FileUtils {
'files' => $storage['files'],
'available' => $storage['available'] ? 'true' : 'false',
'last_checked' => $storage['last_checked']?->format(\DATE_ATOM),
+ 'external_mount_id' => $storage['mount_id'],
];
}