File tree Expand file tree Collapse file tree 1 file changed +2
-15
lines changed
Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Original file line number Diff line number Diff line change 88"""
99
1010from collections import defaultdict
11- import hashlib
1211import sys
1312
1413from fs import open_fs
1514
1615
17- def get_hash (bin_file ):
18- """Get the md5 hash of a file."""
19- file_hash = hashlib .md5 ()
20- while True :
21- chunk = bin_file .read (1024 * 1024 )
22- if not chunk :
23- break
24- file_hash .update (chunk )
25- return file_hash .hexdigest ()
26-
27-
2816hashes = defaultdict (list )
2917with open_fs (sys .argv [1 ]) as fs :
3018 for path in fs .walk .files ():
31- with fs .open (path , "rb" ) as bin_file :
32- file_hash = get_hash (bin_file )
19+ file_hash = fs .hash (path , "md5" )
3320 hashes [file_hash ].append (path )
3421
3522for paths in hashes .values ():
3623 if len (paths ) > 1 :
3724 for path in paths :
38- print (f" { path } " )
25+ print (path )
3926 print ()
4027
You can’t perform that action at this time.
0 commit comments