by default save/load to home

master
Avril 4 years ago
parent 2363f0e874
commit 6e051b15d6
Signed by: flanchan
GPG Key ID: 284488987C31F630

117
Cargo.lock generated

@ -6,18 +6,47 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034"
[[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.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.0.0" version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "base64"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.1" version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "blake2b_simd"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a"
dependencies = [
"arrayref",
"arrayvec",
"constant_time_eq",
]
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.9.0" version = "0.9.0"
@ -59,12 +88,29 @@ dependencies = [
"time", "time",
] ]
[[package]]
name = "constant_time_eq"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
[[package]] [[package]]
name = "cpuid-bool" name = "cpuid-bool"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d375c433320f6c5057ae04a04376eef4d04ce2801448cf8863a78da99107be4" checksum = "6d375c433320f6c5057ae04a04376eef4d04ce2801448cf8863a78da99107be4"
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg",
"cfg-if",
"lazy_static",
]
[[package]] [[package]]
name = "digest" name = "digest"
version = "0.9.0" version = "0.9.0"
@ -74,6 +120,27 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "dirs"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
dependencies = [
"cfg-if",
"dirs-sys",
]
[[package]]
name = "dirs-sys"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a"
dependencies = [
"libc",
"redox_users",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
@ -214,6 +281,17 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "getrandom"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.15" version = "0.1.15"
@ -464,6 +542,17 @@ version = "0.1.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
[[package]]
name = "redox_users"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431"
dependencies = [
"getrandom",
"redox_syscall",
"rust-argon2",
]
[[package]] [[package]]
name = "rmdupe" name = "rmdupe"
version = "1.0.0" version = "1.0.0"
@ -472,10 +561,23 @@ dependencies = [
"futures", "futures",
"lazy_static", "lazy_static",
"sha2", "sha2",
"shellexpand",
"tokio", "tokio",
"tokio-test", "tokio-test",
] ]
[[package]]
name = "rust-argon2"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017"
dependencies = [
"base64",
"blake2b_simd",
"constant_time_eq",
"crossbeam-utils",
]
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.2.3" version = "0.2.3"
@ -519,6 +621,15 @@ dependencies = [
"opaque-debug", "opaque-debug",
] ]
[[package]]
name = "shellexpand"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c7e79eddc7b411f9beeaaf2d421de7e7cb3b1ab9eaf1b79704c0e4130cba6b5"
dependencies = [
"dirs",
]
[[package]] [[package]]
name = "signal-hook-registry" name = "signal-hook-registry"
version = "1.2.0" version = "1.2.0"
@ -632,6 +743,12 @@ version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.2.8" version = "0.2.8"

@ -22,4 +22,5 @@ tokio = { version = "0.2", features = ["full"], optional = true }
sha2 = "0.9" sha2 = "0.9"
futures = { version = "0.3", optional = true } futures = { version = "0.3", optional = true }
lazy_static = "1.4" lazy_static = "1.4"
chrono = "0.4" chrono = "0.4"
shellexpand = "1.1"

@ -143,10 +143,10 @@ where I: IntoIterator<Item=String>
"--" => reading = false, "--" => reading = false,
"--load" => { "--load" => {
load.push(validate_path(config::DEFAULT_HASHNAME, Ensure::File, false)?.to_owned()); load.push(validate_path(config::DEFAULT_HASHNAME.to_string(), Ensure::File, false)?.to_owned());
}, },
"--save" => { "--save" => {
save.push(validate_path(config::DEFAULT_HASHNAME, Ensure::File, false)?.to_owned()); save.push(validate_path(config::DEFAULT_HASHNAME.to_string(), Ensure::File, false)?.to_owned());
}, },
"--save-file" if take_one!() => { "--save-file" if take_one!() => {
save.push(validate_path(&one, Ensure::File, false)?.to_owned()); save.push(validate_path(&one, Ensure::File, false)?.to_owned());
@ -187,8 +187,8 @@ where I: IntoIterator<Item=String>
// Parse small ones // Parse small ones
for argchar in arg.chars().skip(1) { for argchar in arg.chars().skip(1) {
match argchar { match argchar {
'l' => load.push(validate_path(config::DEFAULT_HASHNAME, Ensure::File, false)?.to_owned()), 'l' => load.push(validate_path(config::DEFAULT_HASHNAME.to_owned(), Ensure::File, false)?.to_owned()),
's' => save.push(validate_path(config::DEFAULT_HASHNAME, Ensure::File, false)?.to_owned()), 's' => save.push(validate_path(config::DEFAULT_HASHNAME.to_owned(), Ensure::File, false)?.to_owned()),
'd' => delete = true, 'd' => delete = true,
'v' => mode_log = log::Mode::Verbose, 'v' => mode_log = log::Mode::Verbose,

@ -1,4 +1,5 @@
use super::*; use super::*;
use lazy_static::lazy_static;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum RecursionMode pub enum RecursionMode
@ -38,7 +39,19 @@ impl Default for Mode
} }
} }
pub const DEFAULT_HASHNAME: &'static str = ".rmdupe"; lazy_static! {
pub static ref DEFAULT_HASHNAME: &'static str = {
let string = expand_path(DEFAULT_HASHNAME_STRING);
Box::leak(string.into_boxed_str())
};
}
const DEFAULT_HASHNAME_STRING: &'static str = "~/.rmdupe";
/// Expand path for shell
fn expand_path(path: impl AsRef<str>) -> String
{
shellexpand::tilde(path.as_ref()).to_string()
}
#[derive(Debug)] #[derive(Debug)]
pub struct Config pub struct Config

Loading…
Cancel
Save