From 64a4d72230c8b62a734e8305fba9e4487ca9afcd Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Mon, 17 Aug 2026 22:19:00 +0200 Subject: [PATCH] Read NC connector status from web-readable runtime status path --- include/nc_connector_system.inc.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/include/nc_connector_system.inc.php b/include/nc_connector_system.inc.php index 84c20b5..4994249 100644 --- a/include/nc_connector_system.inc.php +++ b/include/nc_connector_system.inc.php @@ -109,21 +109,34 @@ function bratonien_tools_nc_connector_connection_last_status(array $connection) 'error_detail'=>'', ); + $connection_id = (int)($connection['id'] ?? 0); + $candidates = array(); + if ($connection_id > 0) + { + $candidates[] = '/var/lib/bratonien-tools/nc-connector-status/connection-'.$connection_id.'.json'; + } + $config = isset($connection['config']) && is_array($connection['config']) ? $connection['config'] : array(); $state_dir = rtrim((string)($config['state_dir'] ?? ''), '/'); - - if ($state_dir === '' && !empty($connection['id'])) + if ($state_dir === '' && $connection_id > 0) { - $state_dir = '/var/lib/bratonien-tools/nc-connector/connection-'.(int)$connection['id']; + $state_dir = '/var/lib/bratonien-tools/nc-connector/connection-'.$connection_id; + } + if ($state_dir !== '') + { + $candidates[] = $state_dir.'/connector-status.json'; } - if ($state_dir === '') + $status_path = ''; + foreach ($candidates as $candidate) { - return $empty; + if (is_readable($candidate)) + { + $status_path = $candidate; + break; + } } - - $status_path = $state_dir.'/connector-status.json'; - if (!is_readable($status_path)) + if ($status_path === '') { return $empty; }