Compare commits
2 Commits
da49b29471
...
76d8c4f01a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76d8c4f01a | ||
|
|
d282e8d5d6 |
@ -5,12 +5,16 @@ directories = os.listdir('.') ## Get the files in the current directory
|
|||||||
files = []
|
files = []
|
||||||
|
|
||||||
def quickhash(filefullpath):
|
def quickhash(filefullpath):
|
||||||
with open(filefullpath, "rb" ) as f:
|
try:
|
||||||
md5 = hashlib.md5()
|
with open(filefullpath, "rb" ) as f:
|
||||||
block_size=1024*100
|
md5 = hashlib.md5()
|
||||||
data = f.read(block_size)
|
block_size=1024*100
|
||||||
md5.update(data)
|
data = f.read(block_size)
|
||||||
return md5.digest()
|
md5.update(data)
|
||||||
|
return md5.digest()
|
||||||
|
except OSError as er:
|
||||||
|
print(f"Error hashing {filefullpath}")
|
||||||
|
return None
|
||||||
|
|
||||||
def direcCrawler():
|
def direcCrawler():
|
||||||
global directories, files
|
global directories, files
|
||||||
@ -31,6 +35,7 @@ def calchashes():
|
|||||||
filehashes = {}
|
filehashes = {}
|
||||||
for file in files:
|
for file in files:
|
||||||
hash = quickhash(file)
|
hash = quickhash(file)
|
||||||
|
if hash = None: continue
|
||||||
## Inefficient to use a catch on every non-duplicate (most of the files)
|
## Inefficient to use a catch on every non-duplicate (most of the files)
|
||||||
try: filehashes[hash].append(file)
|
try: filehashes[hash].append(file)
|
||||||
except: filehashes[hash] = [file]
|
except: filehashes[hash] = [file]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user