diff --git a/build-plugin.sh b/build-plugin.sh index da35fd4..d991b9a 100755 --- a/build-plugin.sh +++ b/build-plugin.sh @@ -2,7 +2,7 @@ set -eu PLUGIN="u-navigator" -VERSION="2026.06.23.r046" +VERSION="2026.06.23.r047" PKG_DIR="packages" WORK_DIR=".plugin-build" PKG_NAME="${PLUGIN}-${VERSION}.tgz" diff --git a/packages/u-navigator-2026.06.23.r046.tgz b/packages/u-navigator-2026.06.23.r046.tgz deleted file mode 100644 index 3fd68bc..0000000 Binary files a/packages/u-navigator-2026.06.23.r046.tgz and /dev/null differ diff --git a/packages/u-navigator-2026.06.23.r047.tgz b/packages/u-navigator-2026.06.23.r047.tgz new file mode 100644 index 0000000..5d302cf Binary files /dev/null and b/packages/u-navigator-2026.06.23.r047.tgz differ diff --git a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/upload.php b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/upload.php index fe60f78..acc6832 100644 --- a/plugin-root/usr/local/emhttp/plugins/u-navigator/api/upload.php +++ b/plugin-root/usr/local/emhttp/plugins/u-navigator/api/upload.php @@ -10,24 +10,14 @@ if (!is_dir($target['path'])) { if (isset($_GET['relativePath']) || isset($_SERVER['HTTP_X_UNAV_RELATIVE_PATH'])) { $relativeName = (string)($_GET['relativePath'] ?? $_SERVER['HTTP_X_UNAV_RELATIVE_PATH']); $destination = unav_prepare_upload_destination($target['path'], $relativeName); - $input = fopen('php://input', 'rb'); - $output = fopen($destination['path'], 'xb'); - if (!$input || !$output) { - if ($input) { - fclose($input); - } - if ($output) { - fclose($output); - } - unav_error(500, 'Could not open upload stream'); + $bytes = file_put_contents($destination['path'], file_get_contents('php://input'), LOCK_EX); + if ($bytes === false) { + unav_error(500, 'Could not store uploaded file'); } - stream_copy_to_stream($input, $output); - fclose($input); - fclose($output); unav_json([ 'uploaded' => [[ 'name' => $destination['relative'], - 'size' => filesize($destination['path']) ?: 0, + 'size' => $bytes, ]], ], 201); } diff --git a/server/public/app.js b/server/public/app.js index 5cfd2e0..c29d2cd 100644 --- a/server/public/app.js +++ b/server/public/app.js @@ -915,11 +915,31 @@ async function uploadFileList(win, files, targetPath) { } else { recordDebug('csrf.missing', {}); } - await fetchChecked(apiUrl(`upload.php?${params.toString()}`), { + const response = await fetch(apiUrl(`upload.php?${params.toString()}`), { method: 'POST', headers: { 'Content-Type': 'application/octet-stream' }, body: item.file }); + const text = await response.text(); + recordDebug('upload.file.response', { + path: item.path, + status: response.status, + ok: response.ok, + contentType: response.headers.get('content-type'), + body: text.slice(0, 1000) + }); + if (!response.ok) { + throw new Error(text || `${response.status} ${response.statusText}`); + } + let payload; + try { + payload = JSON.parse(text); + } catch (error) { + throw new Error(`Upload lieferte keine JSON-Antwort: ${text.slice(0, 200) || response.headers.get('content-type') || 'leer'}`); + } + if (!payload.uploaded?.length) { + throw new Error('Upload wurde vom Server nicht bestÃĪtigt.'); + } recordDebug('upload.file.done', { path: item.path, index: index + 1, total: uploadItems.length }); } await loadExplorer(win, targetPath); diff --git a/u-navigator.plg b/u-navigator.plg index 030e657..e48cdde 100644 --- a/u-navigator.plg +++ b/u-navigator.plg @@ -1,7 +1,7 @@ - + @@ -24,7 +24,7 @@ https://git.casaderoll.de/michael/Unraid-Navigator/raw/branch/main/packages/&package; -acb81bdc26294c48b2115013cac89015 +3c9e5a641720371ec7cee8bd70a32d8e