From a52c61556a1a9774a217dc330fd9cbc8c7fbc945 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 2 Feb 2026 01:24:15 +0300 Subject: [PATCH] crates/common: enhance notifications and GC roots handling Signed-off-by: NotAShelf Change-Id: I8a19eeda480672f8f22adbafb3039db66a6a6964 --- crates/common/src/gc_roots.rs | 5 ++--- crates/common/src/notifications.rs | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/common/src/gc_roots.rs b/crates/common/src/gc_roots.rs index 38e8770..4d7882a 100644 --- a/crates/common/src/gc_roots.rs +++ b/crates/common/src/gc_roots.rs @@ -27,8 +27,8 @@ pub fn cleanup_old_roots(roots_dir: &Path, max_age: Duration) -> std::io::Result Err(_) => continue, }; - if let Ok(age) = now.duration_since(modified) { - if age > max_age { + if let Ok(age) = now.duration_since(modified) + && age > max_age { if let Err(e) = std::fs::remove_file(entry.path()) { warn!( "Failed to remove old GC root {}: {e}", @@ -38,7 +38,6 @@ pub fn cleanup_old_roots(roots_dir: &Path, max_age: Duration) -> std::io::Result count += 1; } } - } } Ok(count) diff --git a/crates/common/src/notifications.rs b/crates/common/src/notifications.rs index 56a0a74..6d779ca 100644 --- a/crates/common/src/notifications.rs +++ b/crates/common/src/notifications.rs @@ -18,11 +18,10 @@ pub async fn dispatch_build_finished( } // 2. GitHub commit status - if let Some(ref token) = config.github_token { - if project.repository_url.contains("github.com") { + if let Some(ref token) = config.github_token + && project.repository_url.contains("github.com") { set_github_status(token, &project.repository_url, commit_hash, build).await; } - } // 3. Gitea/Forgejo commit status if let (Some(url), Some(token)) = (&config.gitea_url, &config.gitea_token) { @@ -30,11 +29,10 @@ pub async fn dispatch_build_finished( } // 4. Email notification - if let Some(ref email_config) = config.email { - if !email_config.on_failure_only || build.status == BuildStatus::Failed { + if let Some(ref email_config) = config.email + && (!email_config.on_failure_only || build.status == BuildStatus::Failed) { send_email_notification(email_config, build, project).await; } - } } async fn run_command_notification(cmd: &str, build: &Build, project: &Project) {