🐛 fix: files added during upload now actually get uploaded
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) <noreply@anthropic.com>
This commit is contained in:
parent
00bf6f126d
commit
cb6d61a406
@ -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';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user