feat(uploads): the job carries the duration the file claimed (review F2)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-02 16:45:25 +02:00
co-authored by Claude Sonnet 5.5
parent 12576aa129
commit 132f46b047
+5 -1
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"os"
"time"
"git.d-ma.be/mathias/tapir/internal/domain"
)
@@ -33,6 +34,9 @@ type Job struct {
UserID string
UploadID string
Path string
// Duration is what the file CLAIMED when probed. The worker compares it with what
// was really converted; zero means unknown (ADR-035 review).
Duration time.Duration
}
// Submitter hands accepted jobs to the in-process worker (ADR-033).
@@ -103,7 +107,7 @@ func (in *Intake) Accept(ctx context.Context, userID, title string, src io.Reade
if err != nil {
return "", fmt.Errorf("uploads: create: %w", err)
}
if err := in.sub.Submit(Job{UserID: userID, UploadID: id, Path: path}); err != nil {
if err := in.sub.Submit(Job{UserID: userID, UploadID: id, Path: path, Duration: probe.Duration}); err != nil {
// A row that will never run must not sit queued: that is the stuck spinner.
if ferr := in.store.FailUpload(ctx, userID, id, domain.UploadErrInterrupted); ferr != nil {
return "", fmt.Errorf("uploads: submit: %w (and failing the row: %v)", err, ferr)