TODO: Paranoid dedup

work
Avril 4 years ago
parent 61c78c89ee
commit 6e30736069
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -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. # 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"] 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] [dependencies]
tokio = {version = "0.2", features=["full"]} tokio = {version = "0.2", features=["full"]}

@ -12,6 +12,8 @@ use std::{
}; };
use smallmap::Map; 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<T: Hash>(value: &T) -> u64 fn compute_hash_single<T: Hash>(value: &T) -> u64
{ {
let mut hasher = std::collections::hash_map::DefaultHasher::new(); let mut hasher = std::collections::hash_map::DefaultHasher::new();

@ -11,7 +11,6 @@ use super::*;
use std::{ use std::{
path::{ path::{
Path, Path,
PathBuf,
}, },
}; };

@ -52,15 +52,20 @@ type Pointer = *const Never;
fn install() -> eyre::Result<()> fn install() -> eyre::Result<()>
{ {
pretty_env_logger::init();
color_eyre::install()?; color_eyre::install()?;
Ok(()) Ok(())
} }
/// Process a path for deletion /// Process a path for deletion
///
/// Currently a mock impl
async fn process(state: Arc<state::State>, file: String) async fn process(state: Arc<state::State>, file: String)
{ {
let config = state.config(); let config = state.config();
let _g = state.lock().await;
println!(" -> {:?}", file); println!(" -> {:?}", file);
let dbdir = resolve::mangle_path(&config, &file); let dbdir = resolve::mangle_path(&config, &file);
println!("Database path for this file {:?}", dbdir); println!("Database path for this file {:?}", dbdir);
@ -85,7 +90,7 @@ async fn begin() -> eyre::Result<i32>
{ {
install()?; install()?;
let state = Arc::new(state::State::new(validate_config(config::Config::default()).await 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"); info!("Validated config OK");
if args::process(|file| { if args::process(|file| {
let state = Arc::clone(&state); let state = Arc::clone(&state);
@ -103,7 +108,6 @@ async fn begin() -> eyre::Result<i32>
#[tokio::main] #[tokio::main]
async fn main() -> eyre::Result<()> async fn main() -> eyre::Result<()>
{ {
pretty_env_logger::init();
std::process::exit(match begin().await { std::process::exit(match begin().await {
Ok(0) => return Ok(()), Ok(0) => return Ok(()),
Err(err) => { Err(err) => {

Loading…
Cancel
Save