diff --git a/crates/repo-actor/src/tests/handlers/validate_repo.rs b/crates/repo-actor/src/tests/handlers/validate_repo.rs index 2f33a0dc..c7479eed 100644 --- a/crates/repo-actor/src/tests/handlers/validate_repo.rs +++ b/crates/repo-actor/src/tests/handlers/validate_repo.rs @@ -354,7 +354,7 @@ async fn should_reject_message_with_expired_token() -> TestResult { } #[test_log::test(actix::test)] -// NOTE: failed then passed on retry: count = 2 +// NOTE: failed then passed on retry: count = 3 async fn should_send_validate_repo_when_retryable_error() -> TestResult { //given let fs = given::a_filesystem(); diff --git a/crates/server-actor/src/lib.rs b/crates/server-actor/src/lib.rs index 8ccfbc7f..15dcb0dc 100644 --- a/crates/server-actor/src/lib.rs +++ b/crates/server-actor/src/lib.rs @@ -65,7 +65,6 @@ impl Handler for Server { impl Handler for Server { type Result = (); - #[allow(clippy::cognitive_complexity)] // TODO: (#75) reduce complexity fn handle(&mut self, msg: ReceiveServerConfig, _ctx: &mut Self::Context) -> Self::Result { let Ok(socket_addr) = msg.http() else { warn!("Unable to parse http.addr"); @@ -76,27 +75,9 @@ impl Handler for Server { } self.generation.inc(); let server_config = msg; - // Server Storage - let dir = server_config.storage().path(); - if !dir.exists() { - info!(?dir, "server storage doesn't exist - creating it"); - if let Err(err) = self.fs.dir_create(dir) { - error!(?err, ?dir, "Failed to create server storage"); - return; - } - } - let Ok(canon) = dir.canonicalize() else { - error!(?dir, "Failed to confirm server storage"); + let Some(server_storage) = self.server_storage(&server_config) else { return; }; - info!(dir = ?canon, "server storage"); - - // Forge directories in Server Storage - let server_storage = server_config.storage(); - if let Err(err) = self.create_forge_data_directories(&server_config, dir) { - error!(?err, "Failure creating forge storage"); - return; - } // Webhook Server info!("Starting Webhook Server..."); @@ -247,4 +228,27 @@ impl Server { info!("Started"); (repo_alias, addr) } + + fn server_storage<'cfg>( + &self, + server_config: &'cfg ReceiveServerConfig, + ) -> Option<&'cfg ServerStorage> { + let server_storage = server_config.storage(); + let dir = server_storage.path(); + if !dir.exists() { + if let Err(err) = self.fs.dir_create(dir) { + error!(?err, ?dir, "Failed to create server storage"); + return None; + } + } + let Ok(canon) = dir.canonicalize() else { + error!(?dir, "Failed to confirm server storage"); + return None; + }; + if let Err(err) = self.create_forge_data_directories(server_config, &canon) { + error!(?err, "Failure creating forge storage"); + return None; + } + Some(server_storage) + } } diff --git a/crates/server/src/lib.rs b/crates/server/src/lib.rs index 8a4003c7..601b0aeb 100644 --- a/crates/server/src/lib.rs +++ b/crates/server/src/lib.rs @@ -40,7 +40,6 @@ pub fn start( info!("Starting Server..."); let execution = async move { - //- let server = Server::new(fs.clone(), net.clone(), repo, sleep_duration).start(); server.do_send(FileUpdated);