upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-01-07 17:16:37 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-01-07 17:16:37 +0000
commit42bf1196003c0b39179d8c9d2c07ecf9a83a4a74 (patch)
treed276dc3ac0e904f595d7ce88c30751112439311c /src
parentb71111cc25b99acab786ece4607cb60e9cbebae4 (diff)
fix: resolve clippy warnings
- Prefix unused variable auth_result with underscore - Prefix unused field git_data_path with underscore in Purgatory struct - Add #[allow(clippy::too_many_arguments)] to handle_receive_pack - Replace len() >= 1 with !is_empty() - Replace .last() with .next_back() on DoubleEndedIterator - Fix doc list item overindentation - Replace map_or(true, ...) with is_none_or(...) - Replace map_or(false, ...) with is_some_and(...)
Diffstat (limited to 'src')
-rw-r--r--src/git/handlers.rs3
-rw-r--r--src/git/sync.rs2
-rw-r--r--src/purgatory/mod.rs6
-rw-r--r--src/purgatory/sync/functions.rs8
-rw-r--r--src/purgatory/sync/throttle.rs4
5 files changed, 12 insertions, 11 deletions
diff --git a/src/git/handlers.rs b/src/git/handlers.rs
index 6d2e2d7..ff55e34 100644
--- a/src/git/handlers.rs
+++ b/src/git/handlers.rs
@@ -181,6 +181,7 @@ pub async fn handle_upload_pack(
181/// * `identifier` - The repository identifier (d tag) for authorization lookup 181/// * `identifier` - The repository identifier (d tag) for authorization lookup
182/// * `owner_pubkey` - The owner's public key (hex) from the URL path, scoping authorization 182/// * `owner_pubkey` - The owner's public key (hex) from the URL path, scoping authorization
183/// * `git_data_path` - Base path for git repositories (for syncing to other owner repos) 183/// * `git_data_path` - Base path for git repositories (for syncing to other owner repos)
184#[allow(clippy::too_many_arguments)]
184pub async fn handle_receive_pack( 185pub async fn handle_receive_pack(
185 repo_path: PathBuf, 186 repo_path: PathBuf,
186 request_body: Bytes, 187 request_body: Bytes,
@@ -204,7 +205,7 @@ pub async fn handle_receive_pack(
204 ); 205 );
205 206
206 // check push is authorised 207 // check push is authorised
207 let auth_result = match authorize_push( 208 let _auth_result = match authorize_push(
208 &database, 209 &database,
209 identifier, 210 identifier,
210 owner_pubkey, 211 owner_pubkey,
diff --git a/src/git/sync.rs b/src/git/sync.rs
index 949d8e1..2f43e6e 100644
--- a/src/git/sync.rs
+++ b/src/git/sync.rs
@@ -1310,7 +1310,7 @@ async fn process_purgatory_pr_events(
1310fn extract_owner_from_repo_path(repo_path: &Path, git_data_path: &Path) -> Option<String> { 1310fn extract_owner_from_repo_path(repo_path: &Path, git_data_path: &Path) -> Option<String> {
1311 let relative = repo_path.strip_prefix(git_data_path).ok()?; 1311 let relative = repo_path.strip_prefix(git_data_path).ok()?;
1312 let components: Vec<_> = relative.components().collect(); 1312 let components: Vec<_> = relative.components().collect();
1313 if components.len() >= 1 { 1313 if !components.is_empty() {
1314 components[0].as_os_str().to_str().map(|s| s.to_string()) 1314 components[0].as_os_str().to_str().map(|s| s.to_string())
1315 } else { 1315 } else {
1316 None 1316 None
diff --git a/src/purgatory/mod.rs b/src/purgatory/mod.rs
index 894c941..9427c71 100644
--- a/src/purgatory/mod.rs
+++ b/src/purgatory/mod.rs
@@ -61,7 +61,7 @@ pub struct Purgatory {
61 /// Maps repository identifier to sync queue entry with timing/backoff state. 61 /// Maps repository identifier to sync queue entry with timing/backoff state.
62 sync_queue: Arc<DashMap<String, SyncQueueEntry>>, 62 sync_queue: Arc<DashMap<String, SyncQueueEntry>>,
63 63
64 git_data_path: PathBuf, 64 _git_data_path: PathBuf,
65} 65}
66 66
67impl Purgatory { 67impl Purgatory {
@@ -71,7 +71,7 @@ impl Purgatory {
71 state_events: Arc::new(DashMap::new()), 71 state_events: Arc::new(DashMap::new()),
72 pr_events: Arc::new(DashMap::new()), 72 pr_events: Arc::new(DashMap::new()),
73 sync_queue: Arc::new(DashMap::new()), 73 sync_queue: Arc::new(DashMap::new()),
74 git_data_path: git_data_path.into(), 74 _git_data_path: git_data_path.into(),
75 } 75 }
76 } 76 }
77 77
@@ -135,7 +135,7 @@ impl Purgatory {
135 if self 135 if self
136 .state_events 136 .state_events
137 .get(identifier) 137 .get(identifier)
138 .map_or(false, |entries| !entries.is_empty()) 138 .is_some_and(|entries| !entries.is_empty())
139 { 139 {
140 return true; 140 return true;
141 } 141 }
diff --git a/src/purgatory/sync/functions.rs b/src/purgatory/sync/functions.rs
index 1b9518d..bb7c0b9 100644
--- a/src/purgatory/sync/functions.rs
+++ b/src/purgatory/sync/functions.rs
@@ -35,7 +35,7 @@ fn extract_domain(url: &str) -> Option<String> {
35 let url = url.strip_prefix("https://").or_else(|| url.strip_prefix("http://"))?; 35 let url = url.strip_prefix("https://").or_else(|| url.strip_prefix("http://"))?;
36 36
37 // Remove user info if present (e.g., "user@host" -> "host") 37 // Remove user info if present (e.g., "user@host" -> "host")
38 let url = url.split('@').last()?; 38 let url = url.split('@').next_back()?;
39 39
40 // Extract host (before first '/' or ':') 40 // Extract host (before first '/' or ':')
41 let host = url.split('/').next()?; 41 let host = url.split('/').next()?;
@@ -63,7 +63,7 @@ fn extract_domain(url: &str) -> Option<String> {
63/// * `ctx` - The sync context providing repository data and OID information 63/// * `ctx` - The sync context providing repository data and OID information
64/// * `identifier` - The repository identifier (d-tag value) 64/// * `identifier` - The repository identifier (d-tag value)
65/// * `domain` - If Some, only return URLs from this specific domain. 65/// * `domain` - If Some, only return URLs from this specific domain.
66/// If None, return any non-throttled URL. 66/// If None, return any non-throttled URL.
67/// * `tried_urls` - URLs that have already been tried (will be skipped) 67/// * `tried_urls` - URLs that have already been tried (will be skipped)
68/// * `throttle_manager` - Used to check if domains are throttled (when domain is None) 68/// * `throttle_manager` - Used to check if domains are throttled (when domain is None)
69/// 69///
@@ -126,7 +126,7 @@ pub async fn sync_identifier_next_url<C: SyncContext + ?Sized>(
126 // Merge and filter out our domain 126 // Merge and filter out our domain
127 let all_urls: HashSet<String> = announcement_urls 127 let all_urls: HashSet<String> = announcement_urls
128 .union(&pr_urls) 128 .union(&pr_urls)
129 .filter(|url| our_domain.map_or(true, |d| !url.contains(d))) 129 .filter(|url| our_domain.is_none_or(|d| !url.contains(d)))
130 .cloned() 130 .cloned()
131 .collect(); 131 .collect();
132 132
@@ -231,7 +231,7 @@ pub async fn get_throttled_domains_with_untried_urls<C: SyncContext + ?Sized>(
231 // Merge and filter out our domain 231 // Merge and filter out our domain
232 let all_urls: HashSet<String> = announcement_urls 232 let all_urls: HashSet<String> = announcement_urls
233 .union(&pr_urls) 233 .union(&pr_urls)
234 .filter(|url| our_domain.map_or(true, |d| !url.contains(d))) 234 .filter(|url| our_domain.is_none_or(|d| !url.contains(d)))
235 .cloned() 235 .cloned()
236 .collect(); 236 .collect();
237 237
diff --git a/src/purgatory/sync/throttle.rs b/src/purgatory/sync/throttle.rs
index 05b0878..e6efe1f 100644
--- a/src/purgatory/sync/throttle.rs
+++ b/src/purgatory/sync/throttle.rs
@@ -152,7 +152,7 @@ impl DomainThrottle {
152 while self 152 while self
153 .request_times 153 .request_times
154 .front() 154 .front()
155 .map_or(false, |t| now.duration_since(*t) >= window) 155 .is_some_and(|t| now.duration_since(*t) >= window)
156 { 156 {
157 self.request_times.pop_front(); 157 self.request_times.pop_front();
158 } 158 }
@@ -299,7 +299,7 @@ impl ThrottleManager {
299 /// Returns true if the domain has no capacity for another request, 299 /// Returns true if the domain has no capacity for another request,
300 /// either due to concurrent limit or rate limit. 300 /// either due to concurrent limit or rate limit.
301 pub fn is_throttled(&self, domain: &str) -> bool { 301 pub fn is_throttled(&self, domain: &str) -> bool {
302 self.throttles.get(domain).map_or(false, |entry| { 302 self.throttles.get(domain).is_some_and(|entry| {
303 let throttle = entry.lock().unwrap(); 303 let throttle = entry.lock().unwrap();
304 !throttle.has_capacity() 304 !throttle.has_capacity()
305 }) 305 })