|
|
|
@ -18,6 +18,23 @@ use std::{
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Handle a detected dupe
|
|
|
|
|
fn handle_dupe<P>(path: P, _mode: &config::Mode) -> Result<(), error::Error>
|
|
|
|
|
where P: AsRef<Path>
|
|
|
|
|
{
|
|
|
|
|
println!(" -> {:?}", path.as_ref());
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Handle a detected dupe async
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
#[cfg(feature="threads")]
|
|
|
|
|
async fn handle_dupe_async<P>(path: P, mode: &config::Mode) -> Result<(), error::Error>
|
|
|
|
|
where P: AsRef<Path>
|
|
|
|
|
{
|
|
|
|
|
handle_dupe(path, mode)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct DupeCount
|
|
|
|
|
{
|
|
|
|
@ -126,8 +143,7 @@ pub fn do_dir<P: AsRef<Path>>(dir: P, depth: usize, set: &mut container::DupeMap
|
|
|
|
|
count += if mode.handle(process_file(&obj, set))?.unwrap_or_default() {
|
|
|
|
|
DupeCount{total: 1, dupes: 0}
|
|
|
|
|
} else {
|
|
|
|
|
println!(" -> {:?}", obj);
|
|
|
|
|
//TODO: Delete dupe?
|
|
|
|
|
mode.handle(handle_dupe(obj, &cmode))?;
|
|
|
|
|
DupeCount{total: 1, dupes: 1}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
@ -175,9 +191,20 @@ pub fn do_dir_async<P: AsRef<Path> + std::marker::Send + std::marker::Sync + 'st
|
|
|
|
|
} else {
|
|
|
|
|
let set = Arc::clone(&set);
|
|
|
|
|
let mode = mode.clone();
|
|
|
|
|
let cmode = cmode.clone();
|
|
|
|
|
workers.push(tokio::task::spawn(async move {
|
|
|
|
|
match mode.handle(process_file_async(&obj, &set).await) {
|
|
|
|
|
Ok(v) => Ok(v.unwrap_or_default()),
|
|
|
|
|
Ok(v) => {
|
|
|
|
|
if v.unwrap_or_default() {
|
|
|
|
|
Ok(true)
|
|
|
|
|
} else {
|
|
|
|
|
if let Err(e) = mode.handle(handle_dupe_async(obj, &cmode).await) {
|
|
|
|
|
Err(e)
|
|
|
|
|
} else {
|
|
|
|
|
Ok(false)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Err(v) => Err(v),
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|