Repository navigation
fix(ftp): force binary transfer mode to prevent corrupt downloads - #34
dialupdisaster wants to merge 2 commits into
Conversation
suppaftp never sends TYPE on its own, so the session stayed on the server default (usually TYPE A per RFC 959). ASCII mode rewrites line endings and silently corrupted every binary file downloaded via FTP/Nitrado. Issue TYPE I right after login, before any RETR/STOR, for both the FTP and Nitrado connectors (Nitrado delegates to FtpConnector).
Verify the bytes written for each file against the size reported by the connector so silent transfer corruption (for example an ASCII-mode FTP session) aborts the backup instead of producing a corrupt archive. Files whose size is unknown (reported as 0) are skipped.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 26384f0433
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if file.size > 0 && downloaded != file.size { | ||
| bail!( |
There was a problem hiding this comment.
Revalidate remote metadata before rejecting a size mismatch
When backing up a running server, a log or save file can grow between the initial conn.list() and its download. Both FTP and SFTP collect sizes during directory traversal, then download files sequentially without locking or snapshotting them, so a successful binary transfer can legitimately contain more bytes than the stale listing reports. This check now aborts the entire backup without creating an archive in that situation, including for SFTP. Recheck the remote metadata and distinguish a changed source file from a truncated transfer, with an appropriate retry or explicit policy for changing files.
Useful? React with 👍 / 👎.
Description
FTP sessions never sent
TYPEat all, so every connection stayed on the server's default transfer type — usuallyTYPE A(ASCII) per RFC 959. ASCII mode rewrites line endings, which silently corrupts every binary file transferred through FTP or Nitrado (game saves, archives, SQLite databases).This sets
TYPE Ionce after login and before anyRETR/STOR, so it applies to both backup downloads and remote restore uploads. Nitrado inherits the behaviour because it delegates toFtpConnector. SFTP is unaffected.It also adds a post-download size check: if the number of bytes written does not match the size reported by the connector, the backup aborts instead of archiving corrupt data.
Type of change
Checklist
CONTRIBUTING.mdcargo fmt --all -- --checkpasses locallycargo clippy --all-targets -- -D warningspasses locallycargo test --all-targetspasses locally (109 tests)cargo build --releasepasses locallyRelated issues
None.