fix: parse recipient before creating file in upload_init#131
fix: parse recipient before creating file in upload_init#131rubenhensen merged 2 commits intomainfrom
Conversation
Closes #125 Reorders `upload_init` so the request's recipient is parsed first; only on success do we generate a UUID and create the on-disk file. Previously a malformed recipient returned 400 but left an empty UUID-named file behind in `data_dir` that the in-memory `purge_task` could never reap (no `FileState` was inserted on the rejection path). Adds two regression tests against a minimal Rocket harness: - bad recipient: 400 returned and `data_dir` stays empty. - good recipient: 200 returned and exactly one file appears.
|
/dobby fix the conflicts |
…n-files-125 # Conflicts: # src/main.rs
|
Merged Conflicts (both in
Verification on the merged branch:
Approval is preserved (push was a merge commit, not a rebase). Should be mergeable now. |
Closes #125.
Problem
upload_initinsrc/main.rscreated a zero-byte file on disk before validating the request'srecipient. When the recipient was unparseable, the handler returned 400 but the empty UUID-named file indata_dirwas orphaned — the in-memorypurge_taskonly walksStore::expirations, and noFileStatewas ever inserted for that UUID. Repeated bad-recipient requests slowly filldata_dir.Fix
Reorder so the recipient is parsed first. Only on success do we generate the UUID, create the on-disk file, and call
store.create. Mirrors the cleanup-on-error approach already used elsewhere in the upload flow.Tests
Two new regression tests (
tests::upload_init_bad_recipient_does_not_create_fileandtests::upload_init_good_recipient_creates_file) against a minimal Rocket harness insrc/main.rs:400 Bad Requestand thatdata_diris empty afterwards.200 OKand exactly one file appears indata_dir.Both tests use a per-test temp
data_dirso they run in parallel safely.Verification
cargo test— 32 passed, 0 failed (was 30, +2 new)cargo fmt --all -- --check— cleancargo build --release— cleanReviewer quickstart