From 3f39f1f8ae91bbb7f79844c0bfd9fce72309e2f2 Mon Sep 17 00:00:00 2001 From: patrick Date: Fri, 14 Aug 2026 14:18:08 -0400 Subject: [PATCH] fix: drop the add-anyway override from the upload tray Storing the same bytes twice splits reading progress and shelves across two records that can never converge. The skipped row still names the book that holds the file; allow_duplicates stays on the API for a wrong verdict. --- .../lib/components/layout/upload-tray.svelte | 25 ++++--------- frontend/src/lib/state/upload-queue.svelte.ts | 35 +++---------------- 2 files changed, 11 insertions(+), 49 deletions(-) diff --git a/frontend/src/lib/components/layout/upload-tray.svelte b/frontend/src/lib/components/layout/upload-tray.svelte index 9a27cc0..5835ecf 100644 --- a/frontend/src/lib/components/layout/upload-tray.svelte +++ b/frontend/src/lib/components/layout/upload-tray.svelte @@ -118,7 +118,13 @@ {job.error} {:else if duplicates.length > 0} - + + {#if target} {duplicateNote(duplicates)} {/if} - - - {#if job.status === 'skipped' && !queue.active} - - {/if} {:else} diff --git a/frontend/src/lib/state/upload-queue.svelte.ts b/frontend/src/lib/state/upload-queue.svelte.ts index c67db47..3b36a8a 100644 --- a/frontend/src/lib/state/upload-queue.svelte.ts +++ b/frontend/src/lib/state/upload-queue.svelte.ts @@ -21,8 +21,6 @@ export interface UploadJob { * and still carries these, since the reader asked for those files too. */ duplicates?: DuplicateFile[]; - /** Send this one again with `allow_duplicates`, from "Add anyway". */ - force?: boolean; } export interface UploadSummary { @@ -174,27 +172,6 @@ export class UploadQueueState { void this.#run(); } - /** - * Sends a job again, telling the server to store it even though it matched. - * - * The hash samples a small part of the file, so a match is strong evidence - * rather than proof; this is how someone who knows better overrules it. - */ - addAnyway(id: string) { - this.jobs = this.jobs.map((job) => - job.id === id - ? { - ...job, - status: 'queued' as UploadStatus, - force: true, - duplicates: undefined, - error: undefined - } - : job - ); - void this.#run(); - } - async #run(onFinished?: (summary: UploadSummary) => void) { if (this.#running) return; this.#running = true; @@ -217,14 +194,10 @@ export class UploadQueueState { const body = new FormData(); for (const file of job.files) body.append('files', file); - const query = - `library_id=${encodeURIComponent(String(job.libraryId))}` + - (job.force ? '&allow_duplicates=true' : ''); - - const response = await fetch(`/api/books/fromFiles?${query}`, { - method: 'POST', - body - }); + const response = await fetch( + `/api/books/fromFiles?library_id=${encodeURIComponent(String(job.libraryId))}`, + { method: 'POST', body } + ); if (!response.ok) throw new Error(`The server returned ${response.status}`);