diff --git a/build-plugin.sh b/build-plugin.sh index 925847f..8793783 100755 --- a/build-plugin.sh +++ b/build-plugin.sh @@ -2,7 +2,7 @@ set -eu PLUGIN="u-navigator" -VERSION="2026.06.23.r006" +VERSION="2026.06.23.r007" PKG_DIR="packages" WORK_DIR=".plugin-build" PKG_NAME="${PLUGIN}-${VERSION}.tgz" diff --git a/packages/u-navigator-2026.06.23.r006.tgz b/packages/u-navigator-2026.06.23.r006.tgz deleted file mode 100644 index a66c4e1..0000000 Binary files a/packages/u-navigator-2026.06.23.r006.tgz and /dev/null differ diff --git a/packages/u-navigator-2026.06.23.r007.tgz b/packages/u-navigator-2026.06.23.r007.tgz new file mode 100644 index 0000000..0acadf2 Binary files /dev/null and b/packages/u-navigator-2026.06.23.r007.tgz differ diff --git a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/common.php b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/common.php index afe2d8d..89a3c42 100644 --- a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/common.php +++ b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/common.php @@ -32,6 +32,14 @@ function unav_read_only(): bool { return getenv('U_NAV_READ_ONLY') === '1'; } +function unav_function_available(string $name): bool { + if (!function_exists($name)) { + return false; + } + $disabled = array_map('trim', explode(',', (string)ini_get('disable_functions'))); + return !in_array($name, $disabled, true); +} + function unav_json($payload, int $status = 200): void { http_response_code($status); header('Content-Type: application/json; charset=utf-8'); diff --git a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job.php b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job.php index 4fb5d87..dfe7275 100644 --- a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job.php +++ b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/job.php @@ -35,11 +35,22 @@ unav_job_write($job); $worker = __DIR__ . '/job_worker.php'; $php = is_executable('/usr/bin/php') ? '/usr/bin/php' : (PHP_BINARY ?: 'php'); -if (function_exists('exec') && is_file($worker)) { - exec(escapeshellarg($php) . ' ' . escapeshellarg($worker) . ' ' . escapeshellarg($id) . ' > /dev/null 2>&1 &'); -} else { - require $worker; +$started = false; + +if (unav_function_available('exec') && is_file($worker)) { + try { + $exitCode = 0; + @exec(escapeshellarg($php) . ' ' . escapeshellarg($worker) . ' ' . escapeshellarg($id) . ' > /dev/null 2>&1 &', $output, $exitCode); + $started = ($exitCode === 0); + } catch (Throwable $error) { + $started = false; + } +} + +if (!$started) { + require_once $worker; unav_run_job($id); + $job = unav_job_read($id); } unav_json($job, 202); diff --git a/server/public/app.js b/server/public/app.js index ae1ff1a..3b52f25 100644 --- a/server/public/app.js +++ b/server/public/app.js @@ -826,10 +826,17 @@ function startResizeWindow(event, win) { async function api(url, options) { const response = await fetchChecked(url, options); + const text = await response.text(); try { - return await response.json(); + return JSON.parse(text); } catch (error) { - recordDebug('api.json.error', { url, error: serializeError(error) }); + recordDebug('api.json.error', { + url, + status: response.status, + contentType: response.headers.get('content-type'), + body: text.slice(0, 2000), + error: serializeError(error) + }); throw error; } } @@ -837,12 +844,19 @@ async function api(url, options) { async function fetchChecked(url, options) { recordDebug('fetch.request', { url, method: options?.method || 'GET' }); const response = await fetch(url, options); - recordDebug('fetch.response', { url, status: response.status, ok: response.ok }); + recordDebug('fetch.response', { + url, + status: response.status, + ok: response.ok, + contentType: response.headers.get('content-type') + }); if (!response.ok) { let message = `${response.status} ${response.statusText}`; + const text = await response.text(); try { - message = (await response.json()).error || message; + message = JSON.parse(text).error || message; } catch {} + recordDebug('fetch.error.body', { url, status: response.status, body: text.slice(0, 2000) }); throw new Error(message); } return response; diff --git a/u-navigator.plg b/u-navigator.plg index dd18995..620221a 100644 --- a/u-navigator.plg +++ b/u-navigator.plg @@ -1,7 +1,7 @@ - + ]> @@ -14,7 +14,7 @@ https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package; -6079415588844c2e4a3f8aa43f949bd4 +c9e2b618f5907747315c5f17e80b132f