Skip to content

fix(ftp): stream files of unknown size and name the path a server lacks - #635

Merged
linroid merged 1 commit into
mainfrom
fix/ftp-missing-and-unsized-files
Oct 23, 2026
Merged

linroid merged 1 commit into
mainfrom
fix/ftp-missing-and-unsized-files

Conversation

@linroid

@linroid linroid commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Problem

FtpDownloadSource refused any file whose size it couldn't read:

Download failed: SourceError: Source 'ftp' error <- Exception: Unknown file size — file may not exist: ftp://ftp.gnu.org/gnu/
  • A server without SIZE (old or embedded servers) could not be downloaded from at all, even though RETR works.
  • A missing file and a folder failed with the same vague message. The URL was in the exception text, and since there was no detail, the CLI and the apps showed "Source 'ftp' error".
  • RETR refusals (5xx) had no detail either.

Fix

  • Unknown size: a file whose size the server doesn't report now streams over one connection, from byte zero to the end of the transfer, as HTTP content of unknown size does. Every attempt empties the file first, and the segments stay empty. Resuming an unknown-size state restarts the stream.
  • SIZE 550: this means no file at the path (missing or a folder), unless MDTM dates it; a few servers can't size a file that exists. RealFtpClient.size then fails with a SourceError whose detail names the path and the reply (FtpError.noFile). curl and aria2 also treat a 550 to SIZE as "not found".
  • Other 5xx: these replies now carry FTP <code>: <message> as the detail, cut to 200 characters.

After:

Download failed: The server has no file at gnu/no-such-file.tar.gz (FTP 550: Could not get file size.)
Download failed: FTP 550: Is a directory.          # a folder on a server without SIZE

Tests

  • FtpDownloadSourceTest:
    • A server without SIZE streams the file over one connection, with no segments and final progress equal to its size.
    • Resuming an unknown-size state restarts the stream from zero.
  • RealFtpClientSizeTest (jvmTest, against the scripted server, which now answers SIZE and MDTM when given replies):
    • A missing path names the file.
    • A file that MDTM dates is unknown, not missing.
    • A server without SIZE gives an unknown size.
  • FtpErrorTest: the 550 detail.
  • Checked by hand with the CLI:
    • ftp.gnu.org: a missing file and a folder fail with the path named; a real file still downloads in segments.
    • A local pyftpdlib server with SIZE/MDTM removed streams 64 MB with a matching SHA-256, and its missing file and folder say why.

A file whose size the server would not tell, as on servers without
SIZE, could not be downloaded at all: the download failed with
"Unknown file size - file may not exist". A missing file or a folder
failed the same way, with no detail.

- Such a file now streams over one connection from byte zero to the
  end of the transfer, as HTTP content of unknown size does.
- SIZE answering 550 is a path with no file there, missing or a folder,
  unless MDTM dates it: the client fails with "The server has no file at
  <path> (FTP 550: ...)", as curl treats it.
- Other 5xx replies carry the server's reply as the error's detail, so
  the CLI and the apps say "FTP 550: No such file or directory." rather
  than "Source 'ftp' error".
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T18:55:36.279825Z 1409846 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 201 files   2 229 suites   56m 6s ⏱️
15 383 tests 15 115 ✅ 268 💤 0 ❌
18 748 runs  18 480 ✅ 268 💤 0 ❌

Results for commit 1409846.

@linroid
linroid merged commit 9ad8952 into main Oct 23, 2026
15 checks passed
@linroid
linroid deleted the fix/ftp-missing-and-unsized-files branch October 23, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant