🧱 Chunk is a download manager for slow and unstable servers

Zero-byte files cannot be downloaded at all #3

Open cuducos.me
Open opened by cuducos.me

Problem

getDownloadSize treats Content-Length: 0 from a HEAD request as a failure: resp.ContentLength <= 0 leads to "could not get content length" (downloader.go:256-259). An empty file therefore fails before a single chunk is attempted.

Secondary hazard

Even if the size check were bypassed, chunks(0) computes last = -1 and emits a single malformed chunk {0, -1} with range header bytes=0--1 (downloader.go:305-318).

Reproduction (verified)

An empty file always fails with the content-length error.

Suggested fix

Accept ContentLength == 0 as a valid empty file (write it and finish), and guard chunks against non-positive sizes.

Sign up or Sign in to add to the discussion.