Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ linux-secret-service-rt-tokio-crypto-openssl = ["secret-service/rt-tokio-crypto-
linux-no-secret-service = ["linux-default-keyutils"]
linux-default-keyutils = ["linux-keyutils"]


[dependencies]
lazy_static = "1"
once_cell = "1"

[target.'cfg(target_os = "macos")'.dependencies]
security-framework = { version = "2.6", optional = true }
Expand Down
10 changes: 3 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,12 @@ pub fn set_default_credential_builder(new: Box<CredentialBuilder>) {
}

fn build_default_credential(target: Option<&str>, service: &str, user: &str) -> Result<Entry> {
lazy_static::lazy_static! {
static ref DEFAULT: Box<CredentialBuilder> = default::default_credential_builder();
}
static DEFAULT: once_cell::sync::Lazy<Box<CredentialBuilder>> =
once_cell::sync::Lazy::new(|| default::default_credential_builder());
let guard = DEFAULT_BUILDER
.read()
.expect("Poisoned RwLock in keyring-rs: please report a bug!");
let builder = match guard.inner.as_ref() {
Some(builder) => builder,
None => &DEFAULT,
};
let builder = guard.inner.as_ref().unwrap_or_else(|| &DEFAULT);
let credential = builder.build(target, service, user)?;
Ok(Entry { inner: credential })
}
Expand Down