Skip to content

Commit d1764a0

Browse files
committed
fmt
1 parent ee77e9e commit d1764a0

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

src/webserver/database/sql_pseudofunctions.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,13 @@ async fn persist_uploaded_file<'a>(
232232
)
233233
})?;
234234
// remove the WEB_ROOT prefix from the path, but keep the leading slash
235-
let path = "/".to_string() + target_path
236-
.strip_prefix(web_root)?
237-
.to_str()
238-
.with_context(|| {
239-
format!("persist_uploaded_file: unable to convert path {target_path:?} to a string")
240-
})?;
235+
let path = "/".to_string()
236+
+ target_path
237+
.strip_prefix(web_root)?
238+
.to_str()
239+
.with_context(|| {
240+
format!("persist_uploaded_file: unable to convert path {target_path:?} to a string")
241+
})?;
241242
Ok(Some(Cow::Owned(path)))
242243
}
243244

src/webserver/http_request_info.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,14 @@ async fn extract_multipart_post_data(
162162
log::trace!("Parsing multipart field: {}", field_name);
163163
if let Some(filename) = filename {
164164
log::debug!("Extracting file: {field_name} ({filename})");
165-
let extracted = extract_file(http_req, field, &mut limits).await.with_context(
166-
|| format!("Failed to extract file {field_name:?}. Max file size: {:.3} MB", config.max_uploaded_file_size as f32 / 1_000_000.0),
167-
)?;
165+
let extracted = extract_file(http_req, field, &mut limits)
166+
.await
167+
.with_context(|| {
168+
format!(
169+
"Failed to extract file {field_name:?}. Max file size: {:.3} MB",
170+
config.max_uploaded_file_size as f32 / 1_000_000.0
171+
)
172+
})?;
168173
log::trace!("Extracted file {field_name} to {:?}", extracted.file.path());
169174
uploaded_files.push((field_name, extracted));
170175
} else {
@@ -237,7 +242,9 @@ mod test {
237242
serde_json::from_str::<AppConfig>(r#"{"listen_on": "localhost:1234"}"#).unwrap();
238243
let mut service_request = TestRequest::default().to_srv_request();
239244
let app_data = Arc::new(AppState::init(&config).await.unwrap());
240-
let request_info = extract_request_info(&mut service_request, app_data).await.unwrap();
245+
let request_info = extract_request_info(&mut service_request, app_data)
246+
.await
247+
.unwrap();
241248
assert_eq!(request_info.post_variables.len(), 0);
242249
assert_eq!(request_info.uploaded_files.len(), 0);
243250
assert_eq!(request_info.get_variables.len(), 0);
@@ -253,7 +260,9 @@ mod test {
253260
.set_payload("my_array[]=3&my_array[]=Hello%20World&repeated=1&repeated=2")
254261
.to_srv_request();
255262
let app_data = Arc::new(AppState::init(&config).await.unwrap());
256-
let request_info = extract_request_info(&mut service_request, app_data).await.unwrap();
263+
let request_info = extract_request_info(&mut service_request, app_data)
264+
.await
265+
.unwrap();
257266
assert_eq!(
258267
request_info.post_variables,
259268
vec![
@@ -300,7 +309,9 @@ mod test {
300309
)
301310
.to_srv_request();
302311
let app_data = Arc::new(AppState::init(&config).await.unwrap());
303-
let request_info = extract_request_info(&mut service_request, app_data).await.unwrap();
312+
let request_info = extract_request_info(&mut service_request, app_data)
313+
.await
314+
.unwrap();
304315
assert_eq!(
305316
request_info.post_variables,
306317
vec![(

0 commit comments

Comments
 (0)