package dev.photosync.core.upload;

/**
 * What the GUI draws for one row: the job, plus the byte counters that are not
 * worth persisting and would be stale a frame later anyway.
 */
public record QueuedUpload(UploadJob job, long bytesSent, long bytesTotal) {

    public static QueuedUpload idle(UploadJob job) {
        return new QueuedUpload(job, 0L, job.sizeBytes());
    }

    /** 0..1, and 0 rather than NaN when the total is not known yet. */
    public double fraction() {
        if (bytesTotal <= 0L) {
            return 0.0;
        }
        return Math.min(1.0, (double) bytesSent / (double) bytesTotal);
    }
}
