From cb6d61a406787d1e0682f0cea8ffc18fd8bd5d27 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 6 Apr 2026 22:46:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20files=20added=20during=20?= =?UTF-8?q?upload=20now=20actually=20get=20uploaded?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When user added new files during an active upload (drag-drop, picker or folder monitor with pre-selected hosters), the files were pushed to selectedFiles but NO queue jobs were created (because updateUploadView skips buildQueuePreview during uploading=true). The files briefly showed up via folder monitor's direct buildQueuePreview call, but then handleBatchDone → syncSelectedFilesFromQueue removed them from selectedFiles because they had no queue jobs. Now: applyHosterSelection() and folder monitor both detect added files during upload and: 1. Build preview jobs for the new files 2. Reset them to 'queued' status 3. Inject them into the running batch via addJobsToBatch IPC The upload-manager has duplicate protection so re-injection is safe. Co-Authored-By: Claude Opus 4.6 (1M context) --- renderer/app.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/renderer/app.js b/renderer/app.js index 59c77dc..8309a31 100644 --- a/renderer/app.js +++ b/renderer/app.js @@ -119,10 +119,24 @@ async function init() { } } if (newFiles.length > 0) { + const newPaths = new Set(newFiles.map(f => f.path)); selectedFiles.push(...newFiles); buildQueuePreview(); updateUploadView(); - if (fm.autoStart && !uploading && !healthCheckRunning) startUpload(); + if (fm.autoStart && !uploading && !healthCheckRunning) { + startUpload(); + } else if (uploading) { + // Inject new preview jobs into the running batch + const newJobs = queueJobs.filter(j => j.status === 'preview' && newPaths.has(j.file)); + if (newJobs.length > 0) { + newJobs.forEach(j => { j.status = 'queued'; }); + renderQueueTable(); + window.api.addJobsToBatch({ + jobs: newJobs.map(j => ({ id: j.id, file: j.file, fileName: j.fileName, hoster: j.hoster })) + }).then(result => { _markSkippedJobs(result); }).catch(() => {}); + persistQueueStateSoon(true); + } + } } } else { // No pre-selected hosters: open modal @@ -360,11 +374,29 @@ function applyHosterSelection() { selectedUploadHosters = Array.from(document.querySelectorAll('input[data-hoster-modal]:checked')) .map(input => input.dataset.hosterModal); // Move pending files to selectedFiles on confirm + const pendingPaths = new Set(_pendingFiles.map(f => f.path)); if (_pendingFiles.length > 0) { selectedFiles.push(..._pendingFiles); _pendingFiles = []; } renderHosterSummary(); + + // During an active upload, build preview jobs for the new files and inject + // them into the running batch immediately (otherwise they'd be lost on + // handleBatchDone via syncSelectedFilesFromQueue) + if (uploading && pendingPaths.size > 0) { + buildQueuePreview(); // creates 'preview' jobs for new files + const newJobs = queueJobs.filter(j => j.status === 'preview' && pendingPaths.has(j.file)); + if (newJobs.length > 0) { + newJobs.forEach(j => { j.status = 'queued'; }); + renderQueueTable(); + window.api.addJobsToBatch({ + jobs: newJobs.map(j => ({ id: j.id, file: j.file, fileName: j.fileName, hoster: j.hoster })) + }).then(result => { _markSkippedJobs(result); }).catch(() => {}); + persistQueueStateSoon(true); + } + } + updateUploadView(); persistQueueStateSoon(true); // immediate persist after adding files document.getElementById('hosterModal').style.display = 'none';