mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 19:54:31 +00:00
Read NC connector status from web-readable runtime status path
This commit is contained in:
@@ -109,21 +109,34 @@ function bratonien_tools_nc_connector_connection_last_status(array $connection)
|
|||||||
'error_detail'=>'',
|
'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();
|
$config = isset($connection['config']) && is_array($connection['config']) ? $connection['config'] : array();
|
||||||
$state_dir = rtrim((string)($config['state_dir'] ?? ''), '/');
|
$state_dir = rtrim((string)($config['state_dir'] ?? ''), '/');
|
||||||
|
if ($state_dir === '' && $connection_id > 0)
|
||||||
if ($state_dir === '' && !empty($connection['id']))
|
|
||||||
{
|
{
|
||||||
$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 ($status_path === '')
|
||||||
if (!is_readable($status_path))
|
|
||||||
{
|
{
|
||||||
return $empty;
|
return $empty;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user