aboutsummaryrefslogtreecommitdiffstats
path: root/src/file_op.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2025-02-07 12:48:50 +0000
committerGitHub <noreply@github.com>2025-02-07 12:48:50 +0000
commit77b1c1cd0bfab5d4dc5e0994050fabd4a19cdd0f (patch)
tree0b9e157598d2361397ee09e7f196938d284c48f9 /src/file_op.rs
parentchore: clean up (diff)
parentAdd CHANGELOG entry for #1473 (diff)
downloadminiserve-77b1c1cd0bfab5d4dc5e0994050fabd4a19cdd0f.tar.gz
miniserve-77b1c1cd0bfab5d4dc5e0994050fabd4a19cdd0f.zip
Merge branch 'master' into upload-progress-bar
Diffstat (limited to 'src/file_op.rs')
-rw-r--r--src/file_op.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/file_op.rs b/src/file_op.rs
index 9f5902c..76a7234 100644
--- a/src/file_op.rs
+++ b/src/file_op.rs
@@ -61,7 +61,7 @@ async fn handle_multipart(
allow_hidden_paths: bool,
allow_symlinks: bool,
) -> Result<u64, RuntimeError> {
- let field_name = field.name().to_string();
+ let field_name = field.name().expect("No name field found").to_string();
match tokio::fs::metadata(&path).await {
Err(_) => Err(RuntimeError::InsufficientPermissionsError(
@@ -143,12 +143,16 @@ async fn handle_multipart(
};
}
- let filename = field.content_disposition().get_filename().ok_or_else(|| {
- RuntimeError::ParseError(
- "HTTP header".to_string(),
- "Failed to retrieve the name of the file to upload".to_string(),
- )
- })?;
+ let filename = field
+ .content_disposition()
+ .expect("No content-disposition field found")
+ .get_filename()
+ .ok_or_else(|| {
+ RuntimeError::ParseError(
+ "HTTP header".to_string(),
+ "Failed to retrieve the name of the file to upload".to_string(),
+ )
+ })?;
let filename_path = sanitize_path(Path::new(&filename), allow_hidden_paths)
.ok_or_else(|| RuntimeError::InvalidPathError("Invalid file name to upload".to_string()))?;