upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/purgatory
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-24 11:36:39 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-24 11:36:39 +0000
commitc31a313ccf781e54fa15942bc882c1b113d3f590 (patch)
tree0dec673c40a7cff42651c290b8ded5f6d063a8ae /src/purgatory
parent5efdf431a1481f6fb7a17190b62588b81c5b1e65 (diff)
rename: fetch_repository_data -> fetch_repository_data_{excluding,with}_purgatory
The old name was ambiguous - it wasn't clear whether purgatory was included or not. The two variants are now explicitly named: - fetch_repository_data_excluding_purgatory: DB only - fetch_repository_data_with_purgatory: DB + purgatory overlay SyncContext trait method also renamed to fetch_repository_data_with_purgatory to match the free function it delegates to.
Diffstat (limited to 'src/purgatory')
-rw-r--r--src/purgatory/sync/context.rs17
-rw-r--r--src/purgatory/sync/functions.rs6
2 files changed, 16 insertions, 7 deletions
diff --git a/src/purgatory/sync/context.rs b/src/purgatory/sync/context.rs
index 8297515..1bba961 100644
--- a/src/purgatory/sync/context.rs
+++ b/src/purgatory/sync/context.rs
@@ -87,7 +87,10 @@ pub trait SyncContext: Send + Sync {
87 /// 87 ///
88 /// # Returns 88 /// # Returns
89 /// Repository data including announcements and state events 89 /// Repository data including announcements and state events
90 async fn fetch_repository_data(&self, identifier: &str) -> Result<RepositoryData>; 90 async fn fetch_repository_data_with_purgatory(
91 &self,
92 identifier: &str,
93 ) -> Result<RepositoryData>;
91 94
92 /// Get all OIDs needed for purgatory events with this identifier. 95 /// Get all OIDs needed for purgatory events with this identifier.
93 /// 96 ///
@@ -283,7 +286,10 @@ impl SyncContext for RealSyncContext {
283 urls 286 urls
284 } 287 }
285 288
286 async fn fetch_repository_data(&self, identifier: &str) -> Result<RepositoryData> { 289 async fn fetch_repository_data_with_purgatory(
290 &self,
291 identifier: &str,
292 ) -> Result<RepositoryData> {
287 // Use the purgatory-aware variant so that clone URLs from announcements still 293 // Use the purgatory-aware variant so that clone URLs from announcements still
288 // in purgatory (not yet promoted) are available. Without this, the sync loop 294 // in purgatory (not yet promoted) are available. Without this, the sync loop
289 // would find no URLs to fetch from and the announcement could never be promoted 295 // would find no URLs to fetch from and the announcement could never be promoted
@@ -585,7 +591,7 @@ pub mod mock {
585 /// assert_eq!(mock.fetch_log(), vec!["https://github.com/foo/bar.git"]); 591 /// assert_eq!(mock.fetch_log(), vec!["https://github.com/foo/bar.git"]);
586 /// ``` 592 /// ```
587 pub struct MockSyncContext { 593 pub struct MockSyncContext {
588 /// Repository data to return from fetch_repository_data 594 /// Repository data to return from fetch_repository_data_with_purgatory
589 repo_data: RwLock<Option<RepositoryData>>, 595 repo_data: RwLock<Option<RepositoryData>>,
590 596
591 /// Clone URLs available for the repository (from announcements) 597 /// Clone URLs available for the repository (from announcements)
@@ -732,7 +738,10 @@ pub mod mock {
732 self.pr_clone_urls.clone() 738 self.pr_clone_urls.clone()
733 } 739 }
734 740
735 async fn fetch_repository_data(&self, _identifier: &str) -> Result<RepositoryData> { 741 async fn fetch_repository_data_with_purgatory(
742 &self,
743 _identifier: &str,
744 ) -> Result<RepositoryData> {
736 // Return stored repo_data or create a minimal one with clone URLs 745 // Return stored repo_data or create a minimal one with clone URLs
737 if let Some(data) = self.repo_data.read().unwrap().as_ref() { 746 if let Some(data) = self.repo_data.read().unwrap().as_ref() {
738 // Clone the data - this is a test mock so efficiency isn't critical 747 // Clone the data - this is a test mock so efficiency isn't critical
diff --git a/src/purgatory/sync/functions.rs b/src/purgatory/sync/functions.rs
index 9207d58..bd5c0c0 100644
--- a/src/purgatory/sync/functions.rs
+++ b/src/purgatory/sync/functions.rs
@@ -104,7 +104,7 @@ pub async fn sync_identifier_next_url<C: SyncContext + ?Sized>(
104 } 104 }
105 105
106 // 3. Get repository data 106 // 3. Get repository data
107 let repo_data = match ctx.fetch_repository_data(identifier).await { 107 let repo_data = match ctx.fetch_repository_data_with_purgatory(identifier).await {
108 Ok(data) => data, 108 Ok(data) => data,
109 Err(e) => { 109 Err(e) => {
110 debug!( 110 debug!(
@@ -228,7 +228,7 @@ pub async fn get_throttled_domains_with_untried_urls<C: SyncContext + ?Sized>(
228 throttle_manager: &ThrottleManager, 228 throttle_manager: &ThrottleManager,
229 git_naughty_list: &NaughtyListTracker, 229 git_naughty_list: &NaughtyListTracker,
230) -> Vec<ThrottledDomainInfo> { 230) -> Vec<ThrottledDomainInfo> {
231 let repo_data = match ctx.fetch_repository_data(identifier).await { 231 let repo_data = match ctx.fetch_repository_data_with_purgatory(identifier).await {
232 Ok(data) => data, 232 Ok(data) => data,
233 Err(_) => return vec![], 233 Err(_) => return vec![],
234 }; 234 };
@@ -333,7 +333,7 @@ pub async fn sync_identifier_from_url<C: SyncContext + ?Sized>(
333 }; 333 };
334 334
335 // Get repository data for target repo path 335 // Get repository data for target repo path
336 let repo_data = match ctx.fetch_repository_data(identifier).await { 336 let repo_data = match ctx.fetch_repository_data_with_purgatory(identifier).await {
337 Ok(data) => data, 337 Ok(data) => data,
338 Err(e) => { 338 Err(e) => {
339 debug!( 339 debug!(