diff --git a/src/api/generic_server.rs b/src/api/generic_server.rs index d21e7b14..6d9c4865 100644 --- a/src/api/generic_server.rs +++ b/src/api/generic_server.rs @@ -18,7 +18,6 @@ use hyper_util::rt::TokioIo; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::net::{TcpListener, TcpStream}; -// , UnixListener, UnixStream}; use tokio::sync::watch; use tokio::time::{sleep_until, Instant}; @@ -36,6 +35,9 @@ use garage_util::socket_address::UnixOrTCPSocketAddress; use crate::helpers::{BoxBody, ErrorBody}; +#[cfg(unix)] +use tokio::net::{UnixListener, UnixStream}; + pub(crate) trait ApiEndpoint: Send + Sync + 'static { fn name(&self) -> &'static str; fn add_span_attributes(&self, span: SpanRef<'_>); @@ -121,6 +123,7 @@ impl ApiServer { } #[cfg(unix)] UnixOrTCPSocketAddress::UnixSocket(ref path) => { + use std::os::unix::fs::PermissionsExt; if path.exists() { fs::remove_file(path)? } diff --git a/src/block/layout.rs b/src/block/layout.rs index e78f3f08..00e3debb 100644 --- a/src/block/layout.rs +++ b/src/block/layout.rs @@ -279,7 +279,8 @@ impl DataLayout { u16::from_be_bytes([ hash.as_slice()[HASH_DRIVE_BYTES.0], hash.as_slice()[HASH_DRIVE_BYTES.1], - ]) as usize % DRIVE_NPART + ]) as usize + % DRIVE_NPART } fn block_dir_from(&self, hash: &Hash, dir: &PathBuf) -> PathBuf { diff --git a/src/model/helper/locked.rs b/src/model/helper/locked.rs index f8e06add..b541d548 100644 --- a/src/model/helper/locked.rs +++ b/src/model/helper/locked.rs @@ -279,7 +279,8 @@ impl<'a> LockedHelper<'a> { .local_aliases .get(alias_name) .cloned() - .flatten() != Some(bucket_id) + .flatten() + != Some(bucket_id) { return Err(GarageError::Message(format!( "Bucket {:?} does not have alias {} in namespace of key {}", diff --git a/src/web/web_server.rs b/src/web/web_server.rs index c002f0c8..f4cc157b 100644 --- a/src/web/web_server.rs +++ b/src/web/web_server.rs @@ -2,9 +2,11 @@ use std::fs::{self, Permissions}; use std::{convert::Infallible, sync::Arc}; use tokio::net::TcpListener; -// /, UnixListener}; use tokio::sync::watch; +#[cfg(unix)] +use tokio::net::UnixListener; + use hyper::{ body::Incoming as IncomingBody, header::{HeaderValue, HOST}, @@ -98,6 +100,9 @@ impl WebServer { } #[cfg(unix)] UnixOrTCPSocketAddress::UnixSocket(ref path) => { + use garage_api::generic_server::UnixListenerOn; + use std::os::unix::fs::PermissionsExt; + if path.exists() { fs::remove_file(path)? }