Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
agkyra
Commits
7aa82667
Commit
7aa82667
authored
May 14, 2015
by
Giorgos Korfiatis
Browse files
use filecmp instead of hashing
parent
1c92f053
Changes
2
Hide whitespace changes
Inline
Side-by-side
agkyra/syncer/localfs_client.py
View file @
7aa82667
...
...
@@ -19,6 +19,7 @@ import re
import
datetime
import
psutil
import
time
import
filecmp
from
watchdog.observers
import
Observer
from
watchdog.events
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
):
...
...
agkyra/syncer/utils.py
View file @
7aa82667
...
...
@@ -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
=
f
.
read
(
BUF_SIZE
)
if
not
data
:
break
sha256
.
update
(
data
)
return
sha256
.
hexdigest
()
def
time_stamp
():
return
datetime
.
datetime
.
now
().
strftime
(
"%s.%f"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment