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
cfa26bea
Commit
cfa26bea
authored
Jun 05, 2015
by
Giorgos Korfiatis
Browse files
Don't ignore event when moving to/from cache
parent
55716780
Changes
2
Hide whitespace changes
Inline
Side-by-side
agkyra/syncer/localfs_client.py
View file @
cfa26bea
...
...
@@ -632,26 +632,23 @@ class LocalfsFileClient(FileClient):
path
=
utils
.
to_unicode
(
path
)
except
UnicodeDecodeError
as
e
:
return
if
path
.
startswith
(
self
.
CACHEPATH
):
return
rel_path
=
os
.
path
.
relpath
(
path
,
start
=
self
.
ROOTPATH
)
objname
=
utils
.
to_standard_sep
(
rel_path
)
with
self
.
probe_candidates
.
lock
()
as
d
:
d
[
objname
]
=
self
.
none_info
()
cachepath
=
utils
.
from_unicode
(
self
.
CACHEPATH
)
class
EventHandler
(
FileSystemEventHandler
):
def
on_created
(
this
,
event
):
# if not event.is_directory:
# return
path
=
event
.
src_path
if
path
.
startswith
(
cachepath
):
return
logger
.
debug
(
"Handling %s"
%
event
)
handle_path
(
path
)
def
on_deleted
(
this
,
event
):
path
=
event
.
src_path
if
path
.
startswith
(
cachepath
):
return
logger
.
debug
(
"Handling %s"
%
event
)
handle_path
(
path
)
...
...
@@ -659,17 +656,12 @@ class LocalfsFileClient(FileClient):
if
event
.
is_directory
:
return
path
=
event
.
src_path
if
path
.
startswith
(
cachepath
):
return
logger
.
debug
(
"Handling %s"
%
event
)
handle_path
(
path
)
def
on_moved
(
this
,
event
):
src_path
=
event
.
src_path
dest_path
=
event
.
dest_path
if
src_path
.
startswith
(
cachepath
)
or
\
dest_path
.
startswith
(
cachepath
):
return
logger
.
debug
(
"Handling %s"
%
event
)
handle_path
(
src_path
)
handle_path
(
dest_path
)
...
...
test.py
View file @
cfa26bea
...
...
@@ -192,16 +192,20 @@ class AgkyraTest(unittest.TestCase):
f_cache
=
"φ0002cache"
f_upd
=
"φ0002upd"
f_ren
=
"φ0002ren"
f_cached
=
"φ0002cached"
dbefore
=
"δ0002before"
f_out_path
=
self
.
get_path
(
f_out
)
f_cache_path
=
self
.
get_path
(
f_cache
)
f_upd_path
=
self
.
get_path
(
f_upd
)
f_ren_path
=
self
.
get_path
(
f_ren
)
f_cached_path
=
os
.
path
.
join
(
self
.
settings
.
cache_path
,
f_cached
)
dbefore_path
=
self
.
get_path
(
dbefore
)
open
(
f_out_path
,
"a"
).
close
()
open
(
f_cache_path
,
"a"
).
close
()
open
(
f_upd_path
,
"a"
).
close
()
open
(
f_ren_path
,
"a"
).
close
()
open
(
f_cached_path
,
"a"
).
close
()
os
.
mkdir
(
dbefore_path
)
notifier
=
self
.
slave
.
notifier
()
...
...
@@ -236,12 +240,16 @@ class AgkyraTest(unittest.TestCase):
f_ren_new_path
=
self
.
get_path
(
f_ren_new
)
os
.
rename
(
f_ren_path
,
f_ren_new_path
)
f_cached_out_path
=
self
.
get_path
(
f_cached
)
os
.
rename
(
f_cached_path
,
f_cached_out_path
)
time
.
sleep
(
1
)
candidates
=
self
.
slave
.
list_candidate_files
()
self
.
assertEqual
(
sorted
(
candidates
),
sorted
([
fafter
,
dafter
,
f_in
,
f_out
,
f_upd
,
f_ren
,
f_ren_new
]))
f_ren
,
f_ren_new
,
f_cache
,
f_cached
]))
notifier
.
stop
()
def
test_001_probe_and_sync
(
self
):
...
...
@@ -320,11 +328,17 @@ class AgkyraTest(unittest.TestCase):
# now probe upstream too and retry
self
.
s
.
probe_file
(
self
.
s
.
MASTER
,
fil
)
self
.
assert_message
(
messaging
.
UpdateMessage
)
self
.
s
.
start_notifiers
()
self
.
s
.
decide_file_sync
(
fil
)
self
.
assert_message
(
messaging
.
FailedSyncIgnoreDecisionMessage
)
self
.
assert_message
(
messaging
.
SyncMessage
)
self
.
assert_message
(
messaging
.
ConflictStashMessage
)
m
=
self
.
assert_message
(
messaging
.
ConflictStashMessage
)
stash_name
=
m
.
stash_name
self
.
assert_message
(
messaging
.
AckSyncMessage
)
time
.
sleep
(
1
)
self
.
s
.
stop_notifiers
()
local_cands
=
self
.
slave
.
list_candidate_files
()
self
.
assertIn
(
stash_name
,
local_cands
)
def
test_003_dirs
(
self
):
# make local dir with files
...
...
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