]> source.dussan.org Git - nextcloud-server.git/commitdiff
add command to list mounts for user storage-debug-info 42817/head
authorRobin Appelman <robin@icewind.nl>
Mon, 15 Jan 2024 18:38:32 +0000 (19:38 +0100)
committerRobin Appelman <robin@icewind.nl>
Mon, 15 Jan 2024 18:38:32 +0000 (19:38 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
core/Command/Info/UserMounts.php [new file with mode: 0644]
core/register_command.php
lib/composer/composer/LICENSE
lib/composer/composer/autoload_classmap.php
lib/composer/composer/autoload_static.php

diff --git a/core/Command/Info/UserMounts.php b/core/Command/Info/UserMounts.php
new file mode 100644 (file)
index 0000000..e762e3c
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2024 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Core\Command\Info;
+
+use OCP\Files\IRootFolder;
+use OCP\Files\Mount\IMountPoint;
+use OCP\IUserManager;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class UserMounts extends Command {
+       public function __construct(
+               private FileUtils $fileUtils,
+               private IUserManager $userManager,
+               private IRootFolder $rootFolder,
+       ) {
+               parent::__construct();
+       }
+
+       protected function configure(): void {
+               $this
+                       ->setName('info:user:mounts')
+                       ->setDescription('list mounted storages available for a user')
+                       ->addArgument('user', InputArgument::REQUIRED, "User id to get mounted storages for");
+       }
+
+       public function execute(InputInterface $input, OutputInterface $output): int {
+               $userId = $input->getArgument('user');
+               $user = $this->userManager->get($userId);
+               if (!$user) {
+                       $output->writeln("<error>user $userId not found</error>");
+                       return 1;
+               }
+
+               $userFolder = $this->rootFolder->getUserFolder($userId);
+               $mounts = $this->rootFolder->getMountsIn($userFolder->getPath());
+               $mounts[] = $userFolder->getMountPoint();
+               usort($mounts, fn (IMountPoint $a, IMountPoint $b) => $a->getMountPoint() <=> $b->getMountPoint());
+
+               foreach ($mounts as $mount) {
+                       $mountInfo = $this->fileUtils->formatMountType($mount);
+                       $output->writeln("<info>{$mount->getMountPoint()}</info>: $mountInfo");
+               }
+               return 0;
+       }
+}
index 5a6e00c8a2263a66b522487ce69ce26c0b50c190..5cbaad8dd69b5942328bf13d16bf690ab0d05d5a 100644 (file)
@@ -107,6 +107,7 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
 
        $application->add(\OC::$server->get(OC\Core\Command\Info\File::class));
        $application->add(\OC::$server->get(OC\Core\Command\Info\Space::class));
+       $application->add(\OC::$server->get(OC\Core\Command\Info\UserMounts::class));
 
        $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
        $application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->get(LoggerInterface::class)));
index f27399a042d95c4708af3a8c74d35d338763cf8f..62ecfd8d0046b60517ea7370300f52744f1ab85d 100644 (file)
@@ -1,4 +1,3 @@
-
 Copyright (c) Nils Adermann, Jordi Boggiano
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -18,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
-
index 61fd3193fa2fa7ab51b99a72b533e5e18f8c03b2..f0e449ec8833eaa5c2453786313542e14b8911a2 100644 (file)
@@ -1071,6 +1071,7 @@ return array(
     'OC\\Core\\Command\\Info\\File' => $baseDir . '/core/Command/Info/File.php',
     'OC\\Core\\Command\\Info\\FileUtils' => $baseDir . '/core/Command/Info/FileUtils.php',
     'OC\\Core\\Command\\Info\\Space' => $baseDir . '/core/Command/Info/Space.php',
+    'OC\\Core\\Command\\Info\\UserMounts' => $baseDir . '/core/Command/Info/UserMounts.php',
     'OC\\Core\\Command\\Integrity\\CheckApp' => $baseDir . '/core/Command/Integrity/CheckApp.php',
     'OC\\Core\\Command\\Integrity\\CheckCore' => $baseDir . '/core/Command/Integrity/CheckCore.php',
     'OC\\Core\\Command\\Integrity\\SignApp' => $baseDir . '/core/Command/Integrity/SignApp.php',
index eaacd3939c46894e32f4e1bb596385a2f68c93be..14ed7f984b458d1c2d2bebaaf5a536a6d789f069 100644 (file)
@@ -1104,6 +1104,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
         'OC\\Core\\Command\\Info\\File' => __DIR__ . '/../../..' . '/core/Command/Info/File.php',
         'OC\\Core\\Command\\Info\\FileUtils' => __DIR__ . '/../../..' . '/core/Command/Info/FileUtils.php',
         'OC\\Core\\Command\\Info\\Space' => __DIR__ . '/../../..' . '/core/Command/Info/Space.php',
+        'OC\\Core\\Command\\Info\\UserMounts' => __DIR__ . '/../../..' . '/core/Command/Info/UserMounts.php',
         'OC\\Core\\Command\\Integrity\\CheckApp' => __DIR__ . '/../../..' . '/core/Command/Integrity/CheckApp.php',
         'OC\\Core\\Command\\Integrity\\CheckCore' => __DIR__ . '/../../..' . '/core/Command/Integrity/CheckCore.php',
         'OC\\Core\\Command\\Integrity\\SignApp' => __DIR__ . '/../../..' . '/core/Command/Integrity/SignApp.php',