diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-24 10:06:51 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-24 10:06:51 +0200 |
commit | f8cd7cf5c8dc372e0ae37be0e04f52b84b271416 (patch) | |
tree | 0d074e89318669bb223afdc4d57e006146667b21 | |
parent | 9d6f67de12ad4e7335147fae4cfc7fb5817a6d7c (diff) | |
download | obnam2-f8cd7cf5c8dc372e0ae37be0e04f52b84b271416.tar.gz |
refactor: switch from dirs crate to directories-next
It's a higher-level library and a little nicer to use.
-rw-r--r-- | Cargo.lock | 78 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/bin/obnam.rs | 13 |
3 files changed, 22 insertions, 71 deletions
@@ -37,18 +37,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dabe5a181f83789739c194cbe5a897dde195078fac08568d09221fd6137a7ba8" [[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - -[[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -84,17 +72,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] -name = "blake2b_simd" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] - -[[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -205,12 +182,6 @@ dependencies = [ ] [[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] name = "core-foundation" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -233,17 +204,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] -name = "crossbeam-utils" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" -dependencies = [ - "autocfg", - "cfg-if 1.0.0", - "lazy_static", -] - -[[package]] name = "derivative" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -264,19 +224,20 @@ dependencies = [ ] [[package]] -name = "dirs" -version = "3.0.1" +name = "directories-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142995ed02755914747cc6ca76fc7e4583cd18578746716d0508ea6ed558b9ff" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" dependencies = [ - "dirs-sys", + "cfg-if 1.0.0", + "dirs-sys-next", ] [[package]] -name = "dirs-sys" -version = "0.3.5" +name = "dirs-sys-next" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", @@ -1042,7 +1003,7 @@ dependencies = [ "anyhow", "bytesize", "chrono", - "dirs", + "directories-next", "indicatif", "libc", "log", @@ -1375,13 +1336,12 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.3.5" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.1.16", - "redox_syscall 0.1.57", - "rust-argon2", + "getrandom 0.2.2", + "redox_syscall 0.2.5", ] [[package]] @@ -1476,18 +1436,6 @@ dependencies = [ ] [[package]] -name = "rust-argon2" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" -dependencies = [ - "base64 0.13.0", - "blake2b_simd", - "constant_time_eq", - "crossbeam-utils", -] - -[[package]] name = "rustls" version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -13,7 +13,7 @@ repository = "https://gitlab.com/larswirzenius/obnam" anyhow = "1" bytesize = "1" chrono = "0.4" -dirs = "3" +directories-next = "2" indicatif = "0.15" libc = "0.2" log = "0.4" diff --git a/src/bin/obnam.rs b/src/bin/obnam.rs index 1c1c90e..72ce7c2 100644 --- a/src/bin/obnam.rs +++ b/src/bin/obnam.rs @@ -1,4 +1,5 @@ use anyhow::Context; +use directories_next::ProjectDirs; use log::{debug, error, info, LevelFilter}; use log4rs::append::file::FileAppender; use log4rs::config::{Appender, Config, Logger, Root}; @@ -7,6 +8,10 @@ use obnam::cmd::{backup, get_chunk, list, list_files, restore, show_config, show use std::path::{Path, PathBuf}; use structopt::StructOpt; +const QUALIFIER: &str = ""; +const ORG: &str = ""; +const APPLICATION: &str = "obnam"; + fn main() -> anyhow::Result<()> { let opt = Opt::from_args(); let config = load_config(&opt)?; @@ -53,12 +58,10 @@ fn load_config(opt: &Opt) -> Result<ClientConfig, anyhow::Error> { } fn default_config() -> PathBuf { - if let Some(path) = dirs::config_dir() { - path.join("obnam").join("obnam.yaml") - } else if let Some(path) = dirs::home_dir() { - path.join(".config").join("obnam").join("obnam.yaml") + if let Some(dirs) = ProjectDirs::from(QUALIFIER, ORG, APPLICATION) { + dirs.config_dir().join("obnam.yaml") } else { - panic!("can't find config dir or home dir"); + panic!("can't figure out the configuration directory"); } } |