You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
transfer/indexer: say which file blocks a download and what to do (#200)
checkFileExistence reported both outcomes without saying which file it meant, so what
reached the user was "Failed to download file: Failed to check file existence: File
already exists" with no path at all.
For the caller's own destination that is merely terse. For a fragment temp file it
misleads: fragments are downloaded to <root>.temp in the process working directory, and
if one survives an attempt - the copy into the output failed, os.Remove failed, the
process was killed mid-iteration - every later attempt reports "File already exists"
for a file the caller never created. They inspect the output file they asked for, find
nothing wrong, delete it, retry, and get the same error, with nothing indicating what
is actually blocking them.
Name the file in both errors, and at the fragment sites add what to do about it via a
single shared FragmentLeftBehindError rather than six copies of the sentence. The hint
does not repeat the path, since checkFileExistence now supplies it. It is deliberately
fragment-specific: the same ErrFileAlreadyExists is reported for the caller's own
destination, where "remove it" would be bad advice since they may want to keep the file
they already have. Exported because indexer.Client runs the same fragment loops; the
alternative was two unexported copies.
ErrFileAlreadyExists stays wrapped rather than replaced, so the errors.Is checks that
depend on it keep matching - download_dir relies on it in three places.
Reusing the leftover instead was tried in #199 and dropped: checkFileExistence compares
only the merkle root, never the size, and because the root covers zero-padded chunks a
file short by under a chunk of trailing zeros has the same root - 16 bytes and 256
bytes of the same padded content produce identical roots. Telling the caller to remove
it needs no such trust.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments