Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,16 @@ impl MainHandler {
let headers = &field.headers;
let mut target_path = path.to_owned();

let raw_filename = headers.filename.clone().unwrap();
let filename = Path::new(&raw_filename).file_name().unwrap();
let Some(raw_filename) = headers.filename.clone() else {
println!("[Warning]: Skipping field with no filename");
continue;
};

let Some(filename) = Path::new(&raw_filename).file_name() else {
println!("[Warning]: Invalid filename: {raw_filename}");
continue;
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use if-let-else here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheWaWaR

  • Use if-let-else pattern for both filename extraction and validation ✅

Copy link
Owner

@TheWaWaR TheWaWaR Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let Some(raw_filename) = headers.filename.clone() else {
    println!("[Warning]: Skipping field with no filename");
    continue;
};

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run cargo fmt for your code.


target_path.push(filename);
if let Err(errno) = std::fs::File::create(target_path)
.and_then(|mut file| io::copy(&mut data, &mut file))
Expand All @@ -594,7 +602,7 @@ impl MainHandler {
format!("Copy file failed: {errno}"),
));
} else {
println!(" >> File saved: {}", headers.filename.clone().unwrap());
println!(" >> File saved: {raw_filename}");
}
}
Ok(())
Expand Down
Loading