From b970416819cafed8565d0074b61f7e0e69bc9204 Mon Sep 17 00:00:00 2001 From: Marek Date: Mon, 21 Oct 2024 14:05:29 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Arya --- zebra-rpc/src/server.rs | 8 ++++++-- zebra-rpc/src/server/cookie.rs | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/zebra-rpc/src/server.rs b/zebra-rpc/src/server.rs index dbfc0ad7705..73fcde65f6b 100644 --- a/zebra-rpc/src/server.rs +++ b/zebra-rpc/src/server.rs @@ -311,8 +311,12 @@ impl RpcServer { let wait_on_shutdown = move || { span.in_scope(|| { if config.enable_cookie_auth { - cookie::remove_from_disk(&config.cookie_dir) - .expect("Zebra must be able to remove the auth cookie from the disk"); + if let Err(err) = cookie::remove_from_disk(&config.cookie_dir) { + warn!( + ?err, + "unexpectedly could not remove the rpc auth cookie from the disk" + ) + } } info!("Stopping RPC server"); diff --git a/zebra-rpc/src/server/cookie.rs b/zebra-rpc/src/server/cookie.rs index b046871dd92..e287865c7b2 100644 --- a/zebra-rpc/src/server/cookie.rs +++ b/zebra-rpc/src/server/cookie.rs @@ -35,6 +35,8 @@ impl Default for Cookie { /// Writes the given cookie to the given dir. pub fn write_to_disk(cookie: &Cookie, dir: &Path) -> Result<()> { + // Create the directory if needed. + std::fs::create_dir_all(&dir)?; File::create(dir.join(FILE))?.write_all(format!("__cookie__:{}", cookie.0).as_bytes())?; tracing::info!("RPC auth cookie written to disk");