Skip to content

Commit

Permalink
fix ipv6 parsing for zdb
Browse files Browse the repository at this point in the history
also print the full error stack
  • Loading branch information
muhamadazmy committed Oct 16, 2023
1 parent 87965b4 commit 353bdb4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/fungi/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static SCHEMA: &str = include_str!("../../schema/schema.sql");

#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("failed to execute query: {0}")]
#[error("failed to execute query: {0:#}")]
SqlError(#[from] sqlx::Error),

#[error("invalid hash length")]
Expand All @@ -50,10 +50,10 @@ pub enum Error {
#[error("invalid key length")]
InvalidKey,

#[error("io error: {0}")]
#[error("io error: {0:#}")]
IO(#[from] std::io::Error),

#[error("{0}")]
#[error("{0:#}")]
Anyhow(#[from] anyhow::Error),
}

Expand Down
2 changes: 1 addition & 1 deletion src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ where

async fn run(&mut self, (ino, path): Self::Input) -> Self::Output {
if let Err(err) = self.upload(ino, &path).await {
log::error!("failed to upload file ({:?}): {}", path, err);
log::error!("failed to upload file ({:?}): {:#}", path, err);
}
}
}
6 changes: 3 additions & 3 deletions src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum Error {
#[error("store is not available")]
Unavailable,

#[error("compression error: {0}")]
#[error("compression error: {0:#}")]
Compression(#[from] snap::Error),

#[error("encryption error")]
Expand All @@ -56,7 +56,7 @@ pub enum Error {
#[error("multiple error: {0:?}")]
Multiple(Box<Vec<Self>>),

#[error("io error: {0}")]
#[error("io error: {0:#}")]
IO(#[from] std::io::Error),

#[error("url parse error: {0}")]
Expand All @@ -65,7 +65,7 @@ pub enum Error {
UnknownStore(String),
#[error("invalid schema '{0}' expected '{1}'")]
InvalidScheme(String, String),
#[error("other: {0}")]
#[error("{0:#}")]
Other(#[from] anyhow::Error),
}

Expand Down
10 changes: 9 additions & 1 deletion src/store/zdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ fn get_connection_info<U: AsRef<str>>(u: U) -> Result<(ConnectionInfo, Option<St

let (address, namespace) = match u.host() {
Some(host) => {
let addr = ConnectionAddr::Tcp(host.to_string(), u.port().unwrap_or(9900));
let addr = match host {
url::Host::Domain(domain) => domain.to_owned(),
url::Host::Ipv4(ipv4) => ipv4.to_string(),
url::Host::Ipv6(ipv6) => ipv6.to_string(),
};

let addr = ConnectionAddr::Tcp(addr, u.port().unwrap_or(9900));
let ns: Option<String> = u
.path_segments()
.and_then(|s| s.last().map(|s| s.to_owned()));
Expand Down Expand Up @@ -79,7 +85,9 @@ async fn make_inner(url: String) -> Result<Box<dyn Store>> {
password: info.redis.password.take(),
};

log::debug!("connection {:#?}", info);
log::debug!("switching namespace to: {:?}", namespace.namespace);

let mgr =
RedisConnectionManager::new(info).context("failed to create redis connection manager")?;

Expand Down

0 comments on commit 353bdb4

Please sign in to comment.