From 78c2ac3459cea857a048353f7b2d330f0ae2e93b Mon Sep 17 00:00:00 2001 From: Andreas Mieke Date: Thu, 16 Nov 2023 01:13:05 +0100 Subject: [PATCH] fix(win): Fix crash on start on Windows --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + src/main.rs | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index c9f3794..0ba7817 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -445,6 +445,15 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys", +] + [[package]] name = "http" version = "0.2.9" @@ -835,6 +844,7 @@ name = "plex-media-ingest" version = "0.1.0" dependencies = [ "clap", + "home", "infer", "inline_colorization", "inquire", diff --git a/Cargo.toml b/Cargo.toml index 06da5d9..1092291 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] clap = { version = "4.4.7", features = ["derive"] } +home = "0.5.5" infer = "0.15.0" inline_colorization = "0.1.6" inquire = "0.6.2" diff --git a/src/main.rs b/src/main.rs index 1c85a6f..4df1f09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,7 +57,7 @@ fn main() { // Set config path config to home folder, or if provided to specified file let config_path = if args.config.is_none() { - PathBuf::from(std::env::var("HOME").unwrap()).join(".plex-media-ingest").join("config.json") + PathBuf::from(home::home_dir().unwrap_or_default()).join(".plex-media-ingest").join("config.json") } else { args.config.unwrap() };