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:
Diffstat (limited to 'src')
-rw-r--r--src/config.rs21
-rw-r--r--src/nostr/builder.rs30
2 files changed, 19 insertions, 32 deletions
diff --git a/src/config.rs b/src/config.rs
index 320661f..0a867e3 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -562,9 +562,10 @@ impl Config {
562 } 562 }
563 563
564 /// Get effective git data path 564 /// Get effective git data path
565 /// Returns a temp directory when using memory backend, otherwise the configured path 565 /// Returns a temp directory when using memory backend with default path, otherwise the configured path
566 pub fn effective_git_data_path(&self) -> String { 566 pub fn effective_git_data_path(&self) -> String {
567 if self.database_backend == DatabaseBackend::Memory { 567 if self.database_backend == DatabaseBackend::Memory && self.git_data_path == "./data/git" {
568 // Only use default temp directory if git_data_path is still the default value
568 std::env::temp_dir() 569 std::env::temp_dir()
569 .join("ngit-grasp-git") 570 .join("ngit-grasp-git")
570 .to_string_lossy() 571 .to_string_lossy()
@@ -733,9 +734,11 @@ mod tests {
733 } 734 }
734 735
735 #[test] 736 #[test]
736 fn test_memory_backend_uses_temp_dir() { 737 fn test_memory_backend_uses_temp_dir_with_default_path() {
738 // When git_data_path is the default value, memory backend uses temp dir
737 let config = Config { 739 let config = Config {
738 database_backend: DatabaseBackend::Memory, 740 database_backend: DatabaseBackend::Memory,
741 git_data_path: "./data/git".to_string(), // Default value
739 ..Config::for_testing() 742 ..Config::for_testing()
740 }; 743 };
741 let git_path = config.effective_git_data_path(); 744 let git_path = config.effective_git_data_path();
@@ -743,6 +746,18 @@ mod tests {
743 } 746 }
744 747
745 #[test] 748 #[test]
749 fn test_memory_backend_respects_custom_path() {
750 // When git_data_path is explicitly set, memory backend respects it
751 let config = Config {
752 database_backend: DatabaseBackend::Memory,
753 git_data_path: "./custom/git/path".to_string(),
754 ..Config::for_testing()
755 };
756 let git_path = config.effective_git_data_path();
757 assert_eq!(git_path, "./custom/git/path");
758 }
759
760 #[test]
746 fn test_lmdb_backend_uses_configured_path() { 761 fn test_lmdb_backend_uses_configured_path() {
747 let config = Config { 762 let config = Config {
748 database_backend: DatabaseBackend::Lmdb, 763 database_backend: DatabaseBackend::Lmdb,
diff --git a/src/nostr/builder.rs b/src/nostr/builder.rs
index ef1b700..34014db 100644
--- a/src/nostr/builder.rs
+++ b/src/nostr/builder.rs
@@ -103,7 +103,7 @@ impl Nip34WritePolicy {
103 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()); 103 let event_id_str = event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex());
104 104
105 match self.announcement_policy.validate(event).await { 105 match self.announcement_policy.validate(event).await {
106 AnnouncementResult::Accept => { 106 AnnouncementResult::Accept | AnnouncementResult::AcceptArchive => {
107 // Parse announcement to get repository details 107 // Parse announcement to get repository details
108 match RepositoryAnnouncement::from_event(event.clone()) { 108 match RepositoryAnnouncement::from_event(event.clone()) {
109 Ok(announcement) => { 109 Ok(announcement) => {
@@ -166,34 +166,6 @@ impl Nip34WritePolicy {
166 } 166 }
167 } 167 }
168 } 168 }
169 AnnouncementResult::AcceptArchive => {
170 // GRASP-05: Archive mode - accept announcement but don't create bare repository
171 match RepositoryAnnouncement::from_event(event.clone()) {
172 Ok(announcement) => {
173 tracing::info!(
174 "Accepted archive announcement {} for {}/{} (GRASP-05 read-only mirror)",
175 event_id_str,
176 announcement.owner_npub(),
177 announcement.identifier
178 );
179 // Don't create bare repository for archived announcements
180
181 // Check purgatory for state events that might now be authorized
182 self.check_purgatory_state_events_for_identifier(&announcement.identifier)
183 .await;
184
185 WritePolicyResult::Accept
186 }
187 Err(e) => {
188 tracing::warn!(
189 "Failed to parse archive announcement {}: {}",
190 event_id_str,
191 e
192 );
193 WritePolicyResult::reject(format!("Failed to parse announcement: {}", e))
194 }
195 }
196 }
197 AnnouncementResult::Reject(reason) => { 169 AnnouncementResult::Reject(reason) => {
198 tracing::warn!( 170 tracing::warn!(
199 "Rejected repository announcement {}: {}", 171 "Rejected repository announcement {}: {}",