Skip to content

Commit 0f73a60

Browse files
committed
Handle missing reuse parameter correctly
Actually check for missing key, since figment doesn't properly decode `Option<bool>` on it's own. closes: #2976
1 parent 3d1de7b commit 0f73a60

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/lib/src/listener/unix.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::io;
22
use std::path::{Path, PathBuf};
33

44
use either::{Either, Left, Right};
5+
use figment::error::Kind;
56
use tokio::time::{sleep, Duration};
67

78
use crate::fs::NamedFile;
@@ -79,8 +80,11 @@ impl Bind for UnixListener {
7980
let path = endpoint.unix()
8081
.ok_or_else(|| Right(io::Error::other("internal error: invalid endpoint")))?;
8182

82-
let reuse: Option<bool> = rocket.figment().extract_inner("reuse").map_err(Left)?;
83-
Ok(Self::bind(path, reuse.unwrap_or(true)).await.map_err(Right)?)
83+
let reuse: bool = rocket.figment()
84+
.extract_inner("reuse")
85+
.or_else(|e| if e.missing() { Ok(true) } else { Err(e) } )
86+
.map_err(Left)?;
87+
Ok(Self::bind(path, reuse).await.map_err(Right)?)
8488
}
8589

8690
fn bind_endpoint(rocket: &Rocket<Ignite>) -> Result<Endpoint, Self::Error> {

0 commit comments

Comments
 (0)