fix: avoid creating output file on missing RRQ

This commit is contained in:
2025-12-21 13:26:28 +01:00
parent 3f10f68851
commit 6d1fbef957
2 changed files with 124 additions and 76 deletions

View File

@@ -98,6 +98,25 @@ fn netascii_roundtrip_preserves_newlines_and_cr() {
stop_server(&shutdown, handle);
}
#[test]
fn missing_remote_file_does_not_create_local_file() {
let server_root = TempDir::new("pfs_tftp_server_root_missing");
let local_root = TempDir::new("pfs_tftp_local_root_missing");
let (addr, shutdown, handle) = start_server(server_root.path(), true);
let client = Client::new(addr, test_client_config());
let out = local_root.path().join("should_not_exist.bin");
assert!(!out.exists());
let _err = client
.get("does_not_exist.bin", &out, Mode::Octet)
.unwrap_err();
assert!(!out.exists());
stop_server(&shutdown, handle);
}
fn test_client_config() -> ClientConfig {
ClientConfig {
timeout: Duration::from_millis(200),