From 5c63b7ea794cb3141593bfd006916450b49ae1f2 Mon Sep 17 00:00:00 2001 From: ge Date: Wed, 24 Sep 2025 20:47:29 +0300 Subject: [PATCH] fix duplicates report (#1) --- fdup.v | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fdup.v b/fdup.v index 0d1ec28..e2b728c 100644 --- a/fdup.v +++ b/fdup.v @@ -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 }