Skip to content

Commit

Permalink
Consolidate dirs deps (#320)
Browse files Browse the repository at this point in the history
It seems like the project ended up with two different dependencies
providing access to the home directory.
This PR consolidates these dependencies into a single dependency.

I've done so by using the `home` crate since on linux it has 0
dependencies and is well supported due to being a part of the cargo
repo.
But if you'd prefer I could swap this PR to use `dirs-next`.

I would like to avoid `dirs` since it is pulling in strange dependencies
dirs-dev/dirs-sys-rs#26
  • Loading branch information
rukai authored Aug 2, 2024
1 parent 0dae017 commit 9b9e145
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion russh-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version = "0.7.1"
rust-version = "1.65"

[dependencies]
dirs-next = "2.0"
home = "0.5"
futures = { workspace = true }
globset = "0.4.14"
log = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions russh-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Config {
}

pub fn parse_home(host: &str) -> Result<Config, Error> {
let mut home = if let Some(home) = dirs_next::home_dir() {
let mut home = if let Some(home) = home::home_dir() {
home
} else {
return Err(Error::NoHome);
Expand Down Expand Up @@ -135,7 +135,7 @@ pub fn parse(file: &str, host: &str) -> Result<Config, Error> {
"identityfile" => {
let id = value.trim_start();
if id.starts_with("~/") {
if let Some(mut home) = dirs_next::home_dir() {
if let Some(mut home) = home::home_dir() {
home.push(id.split_at(2).1);
config.identity_file = Some(
home.to_str()
Expand Down
2 changes: 1 addition & 1 deletion russh-keys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ byteorder = { workspace = true }
data-encoding = "2.3"
digest = { workspace = true }
der = "0.7"
dirs = "5.0"
home = "0.5"
ecdsa = "0.16"
ed25519-dalek = { version = "2.0", features = ["rand_core", "pkcs8"] }
elliptic-curve = "0.13"
Expand Down
4 changes: 2 additions & 2 deletions russh-keys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ pub fn check_known_hosts_path<P: AsRef<Path>>(

#[cfg(target_os = "windows")]
fn known_hosts_path() -> Result<PathBuf, Error> {
if let Some(home_dir) = dirs::home_dir() {
if let Some(home_dir) = home::home_dir() {
Ok(home_dir.join("ssh").join("known_hosts"))
} else {
Err(Error::NoHomeDir)
Expand All @@ -512,7 +512,7 @@ fn known_hosts_path() -> Result<PathBuf, Error> {

#[cfg(not(target_os = "windows"))]
fn known_hosts_path() -> Result<PathBuf, Error> {
if let Some(home_dir) = dirs::home_dir() {
if let Some(home_dir) = home::home_dir() {
Ok(home_dir.join(".ssh").join("known_hosts"))
} else {
Err(Error::NoHomeDir)
Expand Down

0 comments on commit 9b9e145

Please sign in to comment.