From e2f3e19909ae5cf71d193327b736c81db1a50bb3 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Sun, 2 Nov 2025 17:37:17 +0100 Subject: [PATCH] fix(SelfTest): Skip mapping test if no oc_mounts are available yet Signed-off-by: provokateurin --- lib/SelfTest.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/SelfTest.php b/lib/SelfTest.php index 971be765..e0f8e43a 100644 --- a/lib/SelfTest.php +++ b/lib/SelfTest.php @@ -75,19 +75,22 @@ public function test(string $server, OutputInterface $output, bool $ignoreProxyE // test if the push server can load storage mappings from the db [$storageId, $count] = $this->getStorageIdForTest(); - try { - $retrievedCount = (int)$this->client->get($server . '/test/mapping/' . $storageId, ['nextcloud' => ['allow_local_address' => true], 'verify' => false])->getBody(); - } catch (\Exception $e) { - $msg = $e->getMessage(); - $output->writeln("🗴 can't connect to push server: $msg"); - return self::ERROR_OTHER; - } + // If no admin user was created during the installation, there are no oc_filecache and oc_mounts entries yet, so this check has to be skipped. + if ($storageId !== null) { + try { + $retrievedCount = (int)$this->client->get($server . '/test/mapping/' . $storageId, ['nextcloud' => ['allow_local_address' => true], 'verify' => false])->getBody(); + } catch (\Exception $e) { + $msg = $e->getMessage(); + $output->writeln("🗴 can't connect to push server: $msg"); + return self::ERROR_OTHER; + } - if ((int)$count === $retrievedCount) { - $output->writeln('✓ push server can load mount info from database'); - } else { - $output->writeln("🗴 push server can't load mount info from database"); - return self::ERROR_OTHER; + if ((int)$count === $retrievedCount) { + $output->writeln('✓ push server can load mount info from database'); + } else { + $output->writeln("🗴 push server can't load mount info from database"); + return self::ERROR_OTHER; + } } // test if the push server can reach nextcloud by having it request the cookie