use std::path::Path; use crate::service::gitcmd::{run_git, run_git_soft}; pub async fn run_gc(repo_dir: &Path, timeout_secs: u64) { let dir_str = repo_dir.display().to_string(); match run_git( "sync::gc", repo_dir, vec![ "gc".to_string(), "--prune=now".to_string(), "--quiet".to_string(), ], &[], timeout_secs, ) .await { Ok(_) => {} Err(e) => tracing::warn!(repo_dir = %dir_str, error = %e, "git gc failed"), } } pub async fn run_fsck(repo_dir: &Path, timeout_secs: u64) { let dir_str = repo_dir.display().to_string(); match run_git_soft( "sync::fsck", repo_dir, vec!["fsck".to_string(), "--no-progress".to_string()], &[], timeout_secs, ) .await { Ok(out) => { let stdout = String::from_utf8_lossy(&out.stdout); if stdout.contains("error") || stdout.contains("broken") { tracing::warn!( repo_dir = %dir_str, output = %stdout.trim(), "fsck reported integrity issues" ); } } Err(e) => { tracing::warn!(repo_dir = %dir_str, error = %e, "fsck failed"); } } }