fix the unix side again
Some checks failed
ci/woodpecker/pr/debug Pipeline failed

This commit is contained in:
Michael Zhang 2024-10-21 13:18:09 +00:00
parent 5339e4c41a
commit 38d9c74db5
4 changed files with 14 additions and 4 deletions

View file

@ -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<A: ApiHandler> ApiServer<A> {
}
#[cfg(unix)]
UnixOrTCPSocketAddress::UnixSocket(ref path) => {
use std::os::unix::fs::PermissionsExt;
if path.exists() {
fs::remove_file(path)?
}

View file

@ -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 {

View file

@ -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 {}",

View file

@ -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)?
}