upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/audit_cleanup.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-26 15:42:09 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-26 15:42:09 +0000
commit9d86cf15f0275ffeee4519bd054e3b61dc8992ac (patch)
tree65b5d5ffb2a11b5ecd05d01e63fb5a4a0f8b6e06 /src/audit_cleanup.rs
parenta2ecfc5a63311570f0f90c7ee40117e289639cb8 (diff)
chore: apply cargo fmt and fix clippy warnings
Fix pre-existing clippy lints: - &PathBuf -> &Path in audit_cleanup.rs - too_many_arguments on process_newly_available_git_data, process_purgatory_announcements, and HttpService::new - clone_on_copy for PublicKey (Copy type) in purgatory cleanup loop
Diffstat (limited to 'src/audit_cleanup.rs')
-rw-r--r--src/audit_cleanup.rs24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/audit_cleanup.rs b/src/audit_cleanup.rs
index b976b1f..de78b1b 100644
--- a/src/audit_cleanup.rs
+++ b/src/audit_cleanup.rs
@@ -15,7 +15,7 @@
15//! 15//!
16//! Runs every `AUDIT_CLEANUP_INTERVAL_SECS` seconds. 16//! Runs every `AUDIT_CLEANUP_INTERVAL_SECS` seconds.
17 17
18use std::path::PathBuf; 18use std::path::{Path, PathBuf};
19use std::time::Duration; 19use std::time::Duration;
20 20
21use nostr_sdk::prelude::*; 21use nostr_sdk::prelude::*;
@@ -46,8 +46,12 @@ pub async fn run_audit_cleanup_loop(database: SharedDatabase, git_data_path: Pat
46} 46}
47 47
48/// Perform a single cleanup pass. 48/// Perform a single cleanup pass.
49async fn run_audit_cleanup_once(database: &SharedDatabase, git_data_path: &PathBuf) { 49async fn run_audit_cleanup_once(database: &SharedDatabase, git_data_path: &Path) {
50 let cutoff = Timestamp::from(Timestamp::now().as_secs().saturating_sub(AUDIT_CLEANUP_AGE_SECS)); 50 let cutoff = Timestamp::from(
51 Timestamp::now()
52 .as_secs()
53 .saturating_sub(AUDIT_CLEANUP_AGE_SECS),
54 );
51 55
52 // --- Step 1: Find repo announcements to delete git repos for --- 56 // --- Step 1: Find repo announcements to delete git repos for ---
53 let repo_filter = Filter::new() 57 let repo_filter = Filter::new()
@@ -73,10 +77,7 @@ async fn run_audit_cleanup_once(database: &SharedDatabase, git_data_path: &PathB
73 if repo_path.exists() { 77 if repo_path.exists() {
74 match std::fs::remove_dir_all(&repo_path) { 78 match std::fs::remove_dir_all(&repo_path) {
75 Ok(()) => { 79 Ok(()) => {
76 debug!( 80 debug!("audit_cleanup: deleted git repo {}", repo_path.display());
77 "audit_cleanup: deleted git repo {}",
78 repo_path.display()
79 );
80 repos_deleted += 1; 81 repos_deleted += 1;
81 82
82 // Remove the parent npub directory if it is now empty 83 // Remove the parent npub directory if it is now empty
@@ -131,9 +132,7 @@ async fn run_audit_cleanup_once(database: &SharedDatabase, git_data_path: &PathB
131 } 132 }
132 133
133 // --- Step 2: Delete all audit events from the database --- 134 // --- Step 2: Delete all audit events from the database ---
134 let all_audit_filter = Filter::new() 135 let all_audit_filter = Filter::new().hashtag(AUDIT_TEST_EVENT_TAG).until(cutoff);
135 .hashtag(AUDIT_TEST_EVENT_TAG)
136 .until(cutoff);
137 136
138 match database.delete(all_audit_filter).await { 137 match database.delete(all_audit_filter).await {
139 Ok(()) => { 138 Ok(()) => {
@@ -143,7 +142,10 @@ async fn run_audit_cleanup_once(database: &SharedDatabase, git_data_path: &PathB
143 ); 142 );
144 } 143 }
145 Err(e) => { 144 Err(e) => {
146 error!("audit_cleanup: failed to delete audit events from database: {}", e); 145 error!(
146 "audit_cleanup: failed to delete audit events from database: {}",
147 e
148 );
147 } 149 }
148 } 150 }
149} 151}