diff --git a/Cargo.lock b/Cargo.lock index 56a2a7cee..5d39629ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1307,6 +1307,7 @@ dependencies = [ "crossbeam-channel", "directories-next", "ffmpeg_cmdline_utils", + "file-id", "fun_time", "hamming", "handsome_logger", @@ -1848,6 +1849,15 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "file-id" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6584280525fb2059cba3db2c04abf947a1a29a45ddae89f3870f8281704fafc9" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "filetime" version = "0.2.25" diff --git a/czkawka_core/Cargo.toml b/czkawka_core/Cargo.toml index eb098aa81..32f0f80c2 100644 --- a/czkawka_core/Cargo.toml +++ b/czkawka_core/Cargo.toml @@ -82,6 +82,11 @@ log = "0.4.22" handsome_logger = "0.8" fun_time = { version = "0.3", features = ["log"] } +[target.'cfg(windows)'.dependencies] +# Don't update anymore! This crate has a bug. I've submitted a patch upstream, but the change is breaking. The current code relies on the bug to work correctly! +# Warning by CalunVier 2024.7.15 +file-id = "=0.2.1" + [build-dependencies] rustc_version = "0.4" diff --git a/czkawka_core/src/duplicate.rs b/czkawka_core/src/duplicate.rs index 9212540b4..d07efd227 100644 --- a/czkawka_core/src/duplicate.rs +++ b/czkawka_core/src/duplicate.rs @@ -1229,7 +1229,19 @@ impl PrintResults for DuplicateFinder { #[cfg(target_family = "windows")] fn filter_hard_links(vec_file_entry: &[FileEntry]) -> Vec { - vec_file_entry.to_vec() + let mut inodes: HashSet = HashSet::with_capacity(vec_file_entry.len()); + let mut identical: Vec = Vec::with_capacity(vec_file_entry.len()); + for f in vec_file_entry { + if let Ok(meta) = file_id::get_low_res_file_id(&f.path) { + if let file_id::FileId::HighRes {file_id, ..} = meta { + if !inodes.insert(file_id) { + continue; + } + } + } + identical.push(f.clone()); + } + identical } #[cfg(target_family = "unix")]