Skip to content

Commit abd1f0d

Browse files
committed
style: rustfmt
1 parent 9cfa1da commit abd1f0d

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

src/handlers.rs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,30 +284,53 @@ async fn upload_agent_json(
284284
Json(body): Json<serde_json::Value>,
285285
) -> Result<Json<serde_json::Value>, (StatusCode, Json<serde_json::Value>)> {
286286
let expected = state.config.sudo_password.as_deref().ok_or_else(|| {
287-
(StatusCode::NOT_FOUND, Json(serde_json::json!({"error": "upload_disabled"})))
287+
(
288+
StatusCode::NOT_FOUND,
289+
Json(serde_json::json!({"error": "upload_disabled"})),
290+
)
288291
})?;
289292

290293
let pw = body.get("password").and_then(|v| v.as_str()).unwrap_or("");
291294
if !constant_time_eq(pw.as_bytes(), expected.as_bytes()) {
292-
return Err((StatusCode::UNAUTHORIZED, Json(serde_json::json!({"error": "invalid_password"}))));
295+
return Err((
296+
StatusCode::UNAUTHORIZED,
297+
Json(serde_json::json!({"error": "invalid_password"})),
298+
));
293299
}
294300

295-
let archive_b64 = body.get("archive_base64").and_then(|v| v.as_str()).ok_or_else(|| {
296-
(StatusCode::BAD_REQUEST, Json(serde_json::json!({"error": "missing archive_base64 field"})))
297-
})?;
301+
let archive_b64 = body
302+
.get("archive_base64")
303+
.and_then(|v| v.as_str())
304+
.ok_or_else(|| {
305+
(
306+
StatusCode::BAD_REQUEST,
307+
Json(serde_json::json!({"error": "missing archive_base64 field"})),
308+
)
309+
})?;
298310

299-
let archive_bytes = base64::engine::general_purpose::STANDARD.decode(archive_b64).map_err(|e| {
300-
(StatusCode::BAD_REQUEST, Json(serde_json::json!({"error": format!("invalid base64: {}", e)})))
301-
})?;
311+
let archive_bytes = base64::engine::general_purpose::STANDARD
312+
.decode(archive_b64)
313+
.map_err(|e| {
314+
(
315+
StatusCode::BAD_REQUEST,
316+
Json(serde_json::json!({"error": format!("invalid base64: {}", e)})),
317+
)
318+
})?;
302319

303320
if archive_bytes.is_empty() || archive_bytes.len() > 50 * 1024 * 1024 {
304-
return Err((StatusCode::BAD_REQUEST, Json(serde_json::json!({"error": "archive empty or too large"}))));
321+
return Err((
322+
StatusCode::BAD_REQUEST,
323+
Json(serde_json::json!({"error": "archive empty or too large"})),
324+
));
305325
}
306326

307327
let files_count = {
308328
let cursor = std::io::Cursor::new(&archive_bytes);
309329
let archive = zip::ZipArchive::new(cursor).map_err(|e| {
310-
(StatusCode::BAD_REQUEST, Json(serde_json::json!({"error": format!("invalid zip: {}", e)})))
330+
(
331+
StatusCode::BAD_REQUEST,
332+
Json(serde_json::json!({"error": format!("invalid zip: {}", e)})),
333+
)
311334
})?;
312335
archive.len()
313336
};

0 commit comments

Comments
 (0)