Commit 7aa82667 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

use filecmp instead of hashing

parent 1c92f053
......@@ -19,6 +19,7 @@ import re
import datetime
import psutil
import time
import filecmp
from watchdog.observers import Observer
from import FileSystemEventHandler
......@@ -103,17 +104,7 @@ def eq_float(f1, f2):
def files_equal(f1, f2):
logger.debug("Comparing files: '%s', '%s'" % (f1, f2))
stats1, st1 = get_local_status(f1)
stats2, st2 = get_local_status(f2)
if st1 != st2:
return False
if st1 != LOCAL_FILE:
return True
if stats1[stat.ST_SIZE] != stats2[stat.ST_SIZE]:
return False
hash1 = utils.hash_file(f1)
hash2 = utils.hash_file(f2)
return hash1 == hash2
return filecmp.cmp(f1, f2, shallow=False)
def info_is_unhandled(info):
......@@ -21,8 +21,6 @@ import watchdog.utils
from agkyra.syncer.common import OBJECT_DIRSEP
BUF_SIZE = 65536
def to_local_sep(filename):
return filename.replace(OBJECT_DIRSEP, os.path.sep)
......@@ -54,17 +52,6 @@ def hash_string(s):
return hashlib.sha256(s).hexdigest()
def hash_file(filename, block_size=BUF_SIZE):
sha256 = hashlib.sha256()
with open(filename, 'rb') as f:
while True:
data =
if not data:
return sha256.hexdigest()
def time_stamp():
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment