Compare commits
3 Commits
5c63b7ea79
...
v0.2.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 172c7b920e | |||
| 7d754eba79 | |||
|
|
07d0513958 |
@@ -1,5 +1,10 @@
|
||||
# fdup
|
||||
|
||||
> [!CAUTION]
|
||||
> Recently I've noticed wrong hashsum calculations in some cases (unknown reason for now).
|
||||
>
|
||||
> Different files may be falsely marked as having the same hash! Be careful and do not use the `-remove` option until issue https://github.com/gechandesu/fdup/issues/1 is resolved.
|
||||
|
||||
The dumb tool for finding duplicate files by their hash sums.
|
||||
|
||||
Compile it with `-prod` for better performance:
|
||||
|
||||
11
fdup.v
11
fdup.v
@@ -35,7 +35,7 @@ fn main() {
|
||||
mut app := cli.Command{
|
||||
name: 'fdup'
|
||||
description: 'File duplicates finder'
|
||||
version: '0.2.0'
|
||||
version: '0.2.1'
|
||||
usage: '[DIR...]'
|
||||
execute: find
|
||||
defaults: struct {
|
||||
@@ -286,8 +286,8 @@ enum HashFn {
|
||||
md5
|
||||
}
|
||||
|
||||
fn hashsum(file string, hash_fn HashFn) string {
|
||||
file_bytes := os.read_bytes(file) or { []u8{len: 1} }
|
||||
fn hashsum(file string, hash_fn HashFn) !string {
|
||||
file_bytes := os.read_bytes(file)!
|
||||
defer {
|
||||
unsafe { file_bytes.free() }
|
||||
}
|
||||
@@ -317,7 +317,10 @@ fn calculate_hashsums(tid int, files []string, hash_fn HashFn) map[string]string
|
||||
eprintln('thread ${tid} started with queue of ${files.len} files')
|
||||
mut sums := map[string]string{}
|
||||
for file in files {
|
||||
sums[file] = hashsum(file, hash_fn)
|
||||
sums[file] = hashsum(file, hash_fn) or {
|
||||
eprintln('File ${file} is skipped due read error: ${err}')
|
||||
continue
|
||||
}
|
||||
}
|
||||
return sums
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user