Browse Source

Fixed bug where duplicate hashes were not counted

restore_refactor
Raphael Roberts 7 years ago
parent
commit
e5e0841467
  1. 6
      backup.py

6
backup.py

@ -25,7 +25,7 @@ def file_hash(path, block_size=4096*8):
else: else:
bytes = f.read() bytes = f.read()
_hash.update(bytes) _hash.update(bytes)
return path,_hash.digest()
return _hash.digest()
def hashify(top): def hashify(top):
old_dir = os.getcwd() old_dir = os.getcwd()
@ -39,7 +39,10 @@ def hashify(top):
imohash = _imohash(filepath) imohash = _imohash(filepath)
real_hash = None real_hash = None
if imohash in imo_hashes: if imohash in imo_hashes:
print(filepath)
real_hash = file_hash(filepath) real_hash = file_hash(filepath)
else:
imo_hashes.add(imohash)
ret.append( ret.append(
( (
filepath, filepath,
@ -52,6 +55,7 @@ def hashify(top):
except Exception as e: except Exception as e:
print(e,file) print(e,file)
os.chdir(old_dir) os.chdir(old_dir)
#print(imo_hashes)
return ret return ret
def __init_database__(path): def __init_database__(path):

Loading…
Cancel
Save