Skip to content

Commit 24b2a36

Browse files
committed
dedupe sample_compare
1 parent b55c184 commit 24b2a36

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

xklb/media/dedupe.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ def get_fs_duplicates(args) -> List[dict]:
407407
hash_results = list(pool.map(sample_compare.full_hash_file, check_paths))
408408
hash_groups = defaultdict(list)
409409
for path, hash in zip(check_paths, hash_results):
410-
hash_groups[hash].append(path)
410+
if hash is not None:
411+
hash_groups[hash].append(path)
411412
for paths in hash_groups.values():
412413
if len(paths) > 1:
413414
keep_path = paths[0]

xklb/scripts/sample_compare.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
def full_hash_file(path):
1212
sha256_hash = hashlib.sha256()
1313

14-
with open(path, "rb") as file:
15-
for byte_block in iter(lambda: file.read(1048576), b""):
16-
sha256_hash.update(byte_block)
14+
try:
15+
with open(path, "rb") as file:
16+
for byte_block in iter(lambda: file.read(1048576), b""):
17+
sha256_hash.update(byte_block)
18+
except FileNotFoundError:
19+
return None
1720

1821
return sha256_hash.hexdigest()
1922

0 commit comments

Comments
 (0)