Compare commits
4 Commits
v0.2.0
...
238a27c346
| Author | SHA1 | Date | |
|---|---|---|---|
| 238a27c346 | |||
|
|
510c5ff43f | ||
| 7d754eba79 | |||
|
|
07d0513958 |
11
fdup.v
11
fdup.v
@@ -35,7 +35,7 @@ fn main() {
|
|||||||
mut app := cli.Command{
|
mut app := cli.Command{
|
||||||
name: 'fdup'
|
name: 'fdup'
|
||||||
description: 'File duplicates finder'
|
description: 'File duplicates finder'
|
||||||
version: '0.2.0'
|
version: '0.2.1'
|
||||||
usage: '[DIR...]'
|
usage: '[DIR...]'
|
||||||
execute: find
|
execute: find
|
||||||
defaults: struct {
|
defaults: struct {
|
||||||
@@ -286,8 +286,8 @@ enum HashFn {
|
|||||||
md5
|
md5
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hashsum(file string, hash_fn HashFn) string {
|
fn hashsum(file string, hash_fn HashFn) !string {
|
||||||
file_bytes := os.read_bytes(file) or { []u8{len: 1} }
|
file_bytes := os.read_bytes(file)!
|
||||||
defer {
|
defer {
|
||||||
unsafe { file_bytes.free() }
|
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')
|
eprintln('thread ${tid} started with queue of ${files.len} files')
|
||||||
mut sums := map[string]string{}
|
mut sums := map[string]string{}
|
||||||
for file in files {
|
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
|
return sums
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user