Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Arya <aryasolhi@gmail.com>
  • Loading branch information
upbqdn and arya2 authored Oct 21, 2024
1 parent 736adfb commit b970416
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions zebra-rpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions zebra-rpc/src/server/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit b970416

Please sign in to comment.