From 7496c28663c5b3c8dd48bfcd92369e478ebb2f26 Mon Sep 17 00:00:00 2001 From: Honey Date: Fri, 5 Jun 2026 00:17:48 +0200 Subject: [PATCH] fix: surface first error detail in fix-artist-sort job message for debugging Co-Authored-By: Claude Sonnet 4.6 --- backend/novasonic-server.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/novasonic-server.js b/backend/novasonic-server.js index aaee6ed..85f53cb 100644 --- a/backend/novasonic-server.js +++ b/backend/novasonic-server.js @@ -648,6 +648,7 @@ app.post('/api/fix-artist-sort', async (req, res) => { updateJob(jobId, { status: 'running', progress: 10, message: `${songs.length} Songs gefunden…` }); let done = 0, errors = 0; + const errorDetails = []; const safeArtistDir = sanitize(artistSort.split(/[,;&]/)[0].trim()); for (const ndSong of songs) { @@ -663,7 +664,12 @@ app.post('/api/fix-artist-sort', async (req, res) => { || _findFileRecursive(CONFIG.musicPath, fileName) || _findFileByStemOrRomaji(CONFIG.musicPath, titleStem); if (found) filePath = found; - else { log(jobId, `⚠ Nicht gefunden: ${path.basename(ndSong.path || '')}`); errors++; continue; } + else { + const detail = `Nicht gefunden: ${path.basename(ndSong.path || '')}`; + log(jobId, `⚠ ${detail}`); + errorDetails.push(detail); + errors++; continue; + } } const fileExt = path.extname(filePath); @@ -710,7 +716,9 @@ app.post('/api/fix-artist-sort', async (req, res) => { updateJob(jobId, { progress: 10 + Math.round((done / songs.length) * 80), message: `${done}/${songs.length} Songs aktualisiert…` }); log(jobId, `✅ ${ndSong.title}`); } catch (e) { - log(jobId, `❌ ${ndSong.title}: ${e.message}`); + const detail = `${ndSong.title}: ${e.message}`; + log(jobId, `❌ ${detail}`); + errorDetails.push(detail); errors++; } } @@ -721,7 +729,10 @@ app.post('/api/fix-artist-sort', async (req, res) => { await fetch(`${ndUrl}/rest/startScan?u=${encodeURIComponent(user)}&t=${t}&s=${s}&v=1.16.1&c=novasonic&f=json`, { signal: AbortSignal.timeout(5000) }); } catch {} - const msg = errors > 0 ? `${done} aktualisiert, ${errors} Fehler` : `${done} Songs aktualisiert`; + const firstErr = errorDetails[0] ? ` (${errorDetails[0]})` : ''; + const msg = errors > 0 + ? `${done} aktualisiert, ${errors} Fehler${firstErr}` + : `${done} Songs aktualisiert`; updateJob(jobId, { status: 'done', progress: 100, message: msg }); })().catch(e => updateJob(jobId, { status: 'error', message: e.message })); });