diff options
author | Robin Appelman <robin@icewind.nl> | 2025-05-12 17:35:17 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2025-05-15 11:49:09 +0200 |
commit | cfc41960388af724f4deb211e60a16a5a008855f (patch) | |
tree | 357ae2148e208c52b0ce5e31e143f1bb7c6e1dcf | |
parent | 6927edc9ff8fdc1e698408d58e3911d341c4c3bc (diff) | |
download | nextcloud-server-info-storage-command.tar.gz nextcloud-server-info-storage-command.zip |
feat: add mount id to info:storage(s)info-storage-command
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | core/Command/Info/FileUtils.php | 17 | ||||
-rw-r--r-- | core/Command/Info/Storage.php | 1 |
2 files changed, 11 insertions, 7 deletions
diff --git a/core/Command/Info/FileUtils.php b/core/Command/Info/FileUtils.php index 198cd72bcaa..bc07535a289 100644 --- a/core/Command/Info/FileUtils.php +++ b/core/Command/Info/FileUtils.php @@ -23,14 +23,14 @@ use OCP\Files\IRootFolder; use OCP\Files\Mount\IMountPoint; use OCP\Files\Node; use OCP\Files\NotFoundException; -use OCP\IDBConnection; use OCP\Files\NotPermittedException; +use OCP\IDBConnection; use OCP\Share\IShare; 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( @@ -246,12 +246,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 [ @@ -260,6 +261,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; @@ -273,11 +275,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); @@ -290,6 +293,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'], ]; } } @@ -305,6 +309,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'], ]; } diff --git a/core/Command/Info/Storage.php b/core/Command/Info/Storage.php index 736cc550a93..c1d0e1725ca 100644 --- a/core/Command/Info/Storage.php +++ b/core/Command/Info/Storage.php @@ -12,7 +12,6 @@ use OC\Core\Command\Base; use OCP\IDBConnection; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Storage extends Base { |