From 03d0ad9396a50847a02972d5f33b5a61c7294e16 Mon Sep 17 00:00:00 2001 From: olksdr Date: Tue, 4 Jul 2023 08:42:57 +0000 Subject: [PATCH] deploy: 0cfafc99a8fde7e41a1b57376c353c2104bc45cf --- relay/setup/static.META.html | 2 +- src/relay_server/actors/project_local.rs.html | 76 ++++++++++++++++++- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/relay/setup/static.META.html b/relay/setup/static.META.html index 95fe5e3a18..d16de853a6 100644 --- a/relay/setup/static.META.html +++ b/relay/setup/static.META.html @@ -1 +1 @@ -META in relay::setup - Rust

Static relay::setup::META

source ·
static META: Metadata<'static>
\ No newline at end of file +META in relay::setup - Rust

Static relay::setup::META

source ·
static META: Metadata<'static>
ml> \ No newline at end of file diff --git a/src/relay_server/actors/project_local.rs.html b/src/relay_server/actors/project_local.rs.html index 346ca382ff..2949d4a729 100644 --- a/src/relay_server/actors/project_local.rs.html +++ b/src/relay_server/actors/project_local.rs.html @@ -248,6 +248,41 @@ 248 249 250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285
use std::collections::HashMap;
 use std::ffi::OsStr;
 use std::path::Path;
@@ -357,9 +392,11 @@
             }
         }
 
-        let arc = Arc::new(sanitized);
-        for key in &arc.public_keys {
-            states.insert(key.public_key, arc.clone());
+        // Keep a separate project state per key.
+        let keys = std::mem::take(&mut sanitized.public_keys);
+        for key in keys {
+            sanitized.public_keys = smallvec::smallvec![key.clone()];
+            states.insert(key.public_key, Arc::new(sanitized.clone()));
         }
     }
 
@@ -497,5 +534,38 @@
             project_key,
         )
     }
+
+    #[tokio::test]
+    async fn test_multi_pub_static_config() {
+        let temp = tempfile::tempdir().unwrap();
+
+        let tmp_project_file = "111111.json";
+        let project_key1 = ProjectKey::parse("55f6b2d962564e99832a39890ee4573e").unwrap();
+        let project_key2 = ProjectKey::parse("55bbb2d96256bb9983bb39890bb457bb").unwrap();
+
+        let mut tmp_project_state = ProjectState::allowed();
+        tmp_project_state.public_keys.extend(vec![
+            PublicKeyConfig {
+                public_key: project_key1,
+                numeric_id: None,
+            },
+            PublicKeyConfig {
+                public_key: project_key2,
+                numeric_id: None,
+            },
+        ]);
+
+        // create the project file
+        let project_state = serde_json::to_string(&tmp_project_state).unwrap();
+        tokio::fs::write(temp.path().join(tmp_project_file), project_state.as_bytes())
+            .await
+            .unwrap();
+
+        let extracted_project_state = load_local_states(temp.path()).await.unwrap();
+
+        assert_eq!(extracted_project_state.len(), 2);
+        assert!(extracted_project_state.get(&project_key1).is_some());
+        assert!(extracted_project_state.get(&project_key2).is_some());
+    }
 }
 
\ No newline at end of file