|
|
@ -26,9 +26,10 @@ class Cloner: |
|
|
|
|
|
|
|
def handleFile(self, fileName: str): |
|
|
|
cloneFileName = fileName.replace(self.targetDir, self.backupDir) |
|
|
|
|
|
|
|
cloneHashFileName = cloneFileName + '.md5' |
|
|
|
|
|
|
|
if os.path.exists(cloneFileName): |
|
|
|
with open(cloneFileName + '.md5', 'r') as cloneHashFile, open(fileName, 'rb') as targetFile: |
|
|
|
with open(cloneHashFileName, 'r') as cloneHashFile, open(fileName, 'rb') as targetFile: |
|
|
|
cloneHashFileContent = cloneHashFile.read() |
|
|
|
targetFileContent = targetFile.read() |
|
|
|
realHash = hashlib.md5(targetFileContent).hexdigest() |
|
|
@ -44,7 +45,7 @@ class Cloner: |
|
|
|
'{file} is a new file, added to backup dir'.format(file=fileName)) |
|
|
|
os.system('cp {real} {clone}'.format( |
|
|
|
real=fileName, clone=cloneFileName)) |
|
|
|
with open(cloneFileName + '.md5', 'w') as cloneHashFile, open(fileName, 'rb') as targetFile: |
|
|
|
with open(cloneHashFileName, 'w') as cloneHashFile, open(fileName, 'rb') as targetFile: |
|
|
|
targetFileContent = targetFile.read() |
|
|
|
cloneHashFile.write(hashlib.md5(targetFileContent).hexdigest()) |
|
|
|
|
|
|
|