From 75329838ddd078185951daccdf271709fe3b837b Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Fri, 22 Mar 2024 07:12:14 -0400 Subject: [PATCH] Use `xdg` instead of `directories-next` --- Cargo.lock | 77 +++++---------------------------------------- Cargo.toml | 2 +- src/crates_cache.rs | 6 ++-- 3 files changed, 11 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db92d2f..6396a70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,6 @@ dependencies = [ "bpaf", "cargo_metadata", "csv", - "directories-next", "flate2", "humantime", "humantime-serde", @@ -108,6 +107,7 @@ dependencies = [ "serde_json", "tar", "ureq", + "xdg", ] [[package]] @@ -202,27 +202,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "directories-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dyn-clone" version = "1.0.8" @@ -288,17 +267,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "getrandom" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "hermit-abi" version = "0.3.2" @@ -486,17 +454,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom", - "redox_syscall", - "thiserror", -] - [[package]] name = "regex-automata" version = "0.1.10" @@ -747,26 +704,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "thiserror" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.98", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -846,12 +783,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "wasm-bindgen" version = "0.2.82" @@ -1074,3 +1005,9 @@ checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc" dependencies = [ "libc", ] + +[[package]] +name = "xdg" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" diff --git a/Cargo.toml b/Cargo.toml index 1c614ca..974fe4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ exclude = ["dep_tests/"] [dependencies] cargo_metadata = "0.15.0" csv = "1.1" -directories-next = "2" flate2 = "1" humantime = "2" humantime-serde = "1" @@ -23,6 +22,7 @@ tar = "0.4.30" indicatif = "0.17.0" bpaf = { version = "0.9.1", features = ["derive", "dull-color"] } anyhow = "1.0.28" +xdg = "2.5" [dev-dependencies] schemars = "0.8.3" diff --git a/src/crates_cache.rs b/src/crates_cache.rs index 0f1a3d3..4b04d7a 100644 --- a/src/crates_cache.rs +++ b/src/crates_cache.rs @@ -113,9 +113,9 @@ impl CratesCache { } fn cache_dir() -> Option { - let projects = - directories_next::ProjectDirs::from("", "rust-secure-code", "cargo-supply-chain")?; - Some(projects.cache_dir().to_owned()) + xdg::BaseDirectories::with_prefix("cargo-supply-chain") + .ok() + .map(|base_directories| base_directories.get_cache_home()) } /// Re-download the list from the data dumps.