From 6e30736069f5392716ce70996b0ae3ed3f70a567 Mon Sep 17 00:00:00 2001 From: Avril Date: Sat, 31 Oct 2020 00:12:17 +0000 Subject: [PATCH] TODO: Paranoid dedup --- Cargo.toml | 4 ++++ src/dedup.rs | 2 ++ src/delete.rs | 1 - src/main.rs | 8 ++++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 70afdf0..4e1275a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,10 @@ threads = ["tokio/rt-threaded"] # Use base64 encoding of pathnames instead of SHA256. This can increase speed of database rebuilding, but can also cause files with large pathnames to fail. fast-pathnames = ["base64"] +# Use low-precision argument dedup (64-bit) instead of high (unimplemented) +# +# Currently does nothing as this is the default and only implemented one. +low-prec-arg-dedup = [] [dependencies] tokio = {version = "0.2", features=["full"]} diff --git a/src/dedup.rs b/src/dedup.rs index d3fe966..5a46a3f 100644 --- a/src/dedup.rs +++ b/src/dedup.rs @@ -12,6 +12,8 @@ use std::{ }; use smallmap::Map; +//TODO: Use SHA256 or 512 when not using feature flag `low-prec-arg-dedup`. +//This will produce more false-positives as it it now. fn compute_hash_single(value: &T) -> u64 { let mut hasher = std::collections::hash_map::DefaultHasher::new(); diff --git a/src/delete.rs b/src/delete.rs index b311592..5fb54dc 100644 --- a/src/delete.rs +++ b/src/delete.rs @@ -11,7 +11,6 @@ use super::*; use std::{ path::{ Path, - PathBuf, }, }; diff --git a/src/main.rs b/src/main.rs index 8a35a98..faced7e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,15 +52,20 @@ type Pointer = *const Never; fn install() -> eyre::Result<()> { + pretty_env_logger::init(); color_eyre::install()?; Ok(()) } /// Process a path for deletion +/// +/// Currently a mock impl async fn process(state: Arc, file: String) { let config = state.config(); + let _g = state.lock().await; + println!(" -> {:?}", file); let dbdir = resolve::mangle_path(&config, &file); println!("Database path for this file {:?}", dbdir); @@ -85,7 +90,7 @@ async fn begin() -> eyre::Result { install()?; let state = Arc::new(state::State::new(validate_config(config::Config::default()).await - .wrap_err(eyre!("Failed to validate config"))?)); + .wrap_err(eyre!("Failed to validate config"))?)); info!("Validated config OK"); if args::process(|file| { let state = Arc::clone(&state); @@ -103,7 +108,6 @@ async fn begin() -> eyre::Result #[tokio::main] async fn main() -> eyre::Result<()> { - pretty_env_logger::init(); std::process::exit(match begin().await { Ok(0) => return Ok(()), Err(err) => {