Skip to content

Commit a17dbc6

Browse files
authored
fix ipv6 parsing for zdb (#31)
also print the full error stack
1 parent 87965b4 commit a17dbc6

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/fungi/meta.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static SCHEMA: &str = include_str!("../../schema/schema.sql");
4141

4242
#[derive(thiserror::Error, Debug)]
4343
pub enum Error {
44-
#[error("failed to execute query: {0}")]
44+
#[error("failed to execute query: {0:#}")]
4545
SqlError(#[from] sqlx::Error),
4646

4747
#[error("invalid hash length")]
@@ -50,10 +50,10 @@ pub enum Error {
5050
#[error("invalid key length")]
5151
InvalidKey,
5252

53-
#[error("io error: {0}")]
53+
#[error("io error: {0:#}")]
5454
IO(#[from] std::io::Error),
5555

56-
#[error("{0}")]
56+
#[error("{0:#}")]
5757
Anyhow(#[from] anyhow::Error),
5858
}
5959

src/pack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ where
217217

218218
async fn run(&mut self, (ino, path): Self::Input) -> Self::Output {
219219
if let Err(err) = self.upload(ino, &path).await {
220-
log::error!("failed to upload file ({:?}): {}", path, err);
220+
log::error!("failed to upload file ({:?}): {:#}", path, err);
221221
}
222222
}
223223
}

src/store/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub enum Error {
4646
#[error("store is not available")]
4747
Unavailable,
4848

49-
#[error("compression error: {0}")]
49+
#[error("compression error: {0:#}")]
5050
Compression(#[from] snap::Error),
5151

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

59-
#[error("io error: {0}")]
59+
#[error("io error: {0:#}")]
6060
IO(#[from] std::io::Error),
6161

6262
#[error("url parse error: {0}")]
@@ -65,7 +65,7 @@ pub enum Error {
6565
UnknownStore(String),
6666
#[error("invalid schema '{0}' expected '{1}'")]
6767
InvalidScheme(String, String),
68-
#[error("other: {0}")]
68+
#[error("{0:#}")]
6969
Other(#[from] anyhow::Error),
7070
}
7171

src/store/zdb.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ fn get_connection_info<U: AsRef<str>>(u: U) -> Result<(ConnectionInfo, Option<St
4545

4646
let (address, namespace) = match u.host() {
4747
Some(host) => {
48-
let addr = ConnectionAddr::Tcp(host.to_string(), u.port().unwrap_or(9900));
48+
let addr = match host {
49+
url::Host::Domain(domain) => domain.to_owned(),
50+
url::Host::Ipv4(ipv4) => ipv4.to_string(),
51+
url::Host::Ipv6(ipv6) => ipv6.to_string(),
52+
};
53+
54+
let addr = ConnectionAddr::Tcp(addr, u.port().unwrap_or(9900));
4955
let ns: Option<String> = u
5056
.path_segments()
5157
.and_then(|s| s.last().map(|s| s.to_owned()));
@@ -79,7 +85,9 @@ async fn make_inner(url: String) -> Result<Box<dyn Store>> {
7985
password: info.redis.password.take(),
8086
};
8187

88+
log::debug!("connection {:#?}", info);
8289
log::debug!("switching namespace to: {:?}", namespace.namespace);
90+
8391
let mgr =
8492
RedisConnectionManager::new(info).context("failed to create redis connection manager")?;
8593

0 commit comments

Comments
 (0)