Skip to content

Commit 08b233b

Browse files
committed
irondrop: supress finder noise
1 parent 9437d98 commit 08b233b

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/http.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ pub async fn handle_client_async<S>(
349349

350350
match response_result {
351351
Ok(response) => {
352+
// Check if this is a Finder noise 404 before logging and stats
353+
let is_finder_noise = response.status_code == 404
354+
&& crate::utils::is_macos_finder_noise_path(&request_path);
355+
352356
log_request_line(
353357
&log_prefix,
354358
&request_method,
@@ -357,8 +361,10 @@ pub async fn handle_client_async<S>(
357361
);
358362
match send_response_async(&mut stream, response, &log_prefix).await {
359363
Ok(body_bytes) => {
360-
if let Some(stats) = stats {
361-
stats.record_request(true, body_bytes);
364+
if !is_finder_noise {
365+
if let Some(stats) = stats {
366+
stats.record_request(true, body_bytes);
367+
}
362368
}
363369
}
364370
Err(_) => {
@@ -369,12 +375,14 @@ pub async fn handle_client_async<S>(
369375
}
370376
}
371377
Err(e) => {
372-
let ignore_error_for_stats = matches!(e, AppError::NotFound)
378+
let is_finder_noise = matches!(e, AppError::NotFound)
373379
&& request_method == "PROPFIND"
374380
&& crate::utils::is_macos_finder_noise_path(&request_path);
375381
send_error_response_async(&mut stream, e, &log_prefix).await;
376-
if let Some(stats) = stats {
377-
stats.record_request(ignore_error_for_stats, 0);
382+
if !is_finder_noise {
383+
if let Some(stats) = stats {
384+
stats.record_request(false, 0);
385+
}
378386
}
379387
}
380388
}
@@ -390,6 +398,12 @@ fn log_request_line(log_prefix: &str, method: &str, path: &str, status_code: u16
390398
monitor_request_log_rate_limited(method, status_code);
391399
return;
392400
}
401+
// Suppress macOS Finder noise (._files, .Spotlight, .AU.*, etc.) to TRACE
402+
// level to keep logs clean. These are harmless 404s from Finder probing.
403+
if status_code == 404 && crate::utils::is_macos_finder_noise_path(path_only) {
404+
trace!("{log_prefix} {method} {path} -> {status_code} (finder noise)");
405+
return;
406+
}
393407
info!("{log_prefix} {method} {path} -> {status_code}");
394408
}
395409

0 commit comments

Comments
 (0)