Merge lp:~facundo/ubuntuone-client/different-dir-deletion-check into lp:ubuntuone-client

Proposed by Facundo Batista
Status: Merged
Approved by: Facundo Batista
Approved revision: 1190
Merged at revision: 1195
Proposed branch: lp:~facundo/ubuntuone-client/different-dir-deletion-check
Merge into: lp:ubuntuone-client
Diff against target: 75 lines (+17/-2)
2 files modified
tests/syncdaemon/test_eq_inotify.py (+15/-0)
ubuntuone/syncdaemon/filesystem_notifications.py (+2/-2)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/different-dir-deletion-check
Reviewer Review Type Date Requested Status
Facundo Batista (community) Approve
Guillermo Gonzalez Approve
Review via email: mp+92282@code.launchpad.net

Commit message

Check where to call handle_dir_delete in a better place.

Description of the change

Check where to call handle_dir_delete in a better place.

This is to not skip the signal if faked from different move situations.

Tests included.

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

+1

review: Approve
Revision history for this message
Facundo Batista (facundo) wrote :

Approving with one review

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_eq_inotify.py'
2--- tests/syncdaemon/test_eq_inotify.py 2012-01-18 20:47:18 +0000
3+++ tests/syncdaemon/test_eq_inotify.py 2012-02-09 14:42:13 +0000
4@@ -1375,6 +1375,9 @@
5 if path != fromdir:
6 self.finished_error("received a wrong path")
7 else:
8+ # file deletion should remove its watch
9+ self.assertNotIn(path, self.eq.monitor._general_watchs)
10+
11 remove_dir(todir)
12 remove_dir(helpdir)
13 self.finished_ok()
14@@ -1467,6 +1470,11 @@
15 todir = os.path.join(self.root_dir, "bar")
16 make_dir(fromdir)
17
18+ # patch to check proper dir deletion is handled
19+ called = []
20+ self.patch(self.eq.monitor._processor.general_processor,
21+ 'handle_dir_delete', lambda p: called.append(p))
22+
23 # patch the general processor to ignore all that ends with bar
24 self.patch(self.eq.monitor._processor.general_processor, "is_ignored",
25 lambda path: path.endswith("bar"))
26@@ -1479,6 +1487,7 @@
27 # generate the event
28 rename(fromdir, todir)
29 yield self._deferred
30+ self.assertEqual(called, [fromdir])
31
32 @defer.inlineCallbacks
33 def test_file_moved_from_ignored(self):
34@@ -1971,6 +1980,11 @@
35 yield self._create_udf('vol2', base2)
36 self.fs.create(path=base2, share_id='vol2', is_dir=True)
37
38+ # patch to check proper dir deletion is handled
39+ called = []
40+ self.patch(self.eq.monitor._processor.general_processor,
41+ 'handle_dir_delete', lambda p: called.append(p))
42+
43 # working stuff
44 moving1 = os.path.join(base1, "test")
45 moving2 = os.path.join(base2, "test")
46@@ -1987,6 +2001,7 @@
47 # generate the event
48 rename(moving1, moving2)
49 yield self._deferred
50+ self.assertEqual(called, [moving1])
51
52 @defer.inlineCallbacks
53 def test_move_file_across_volumes(self):
54
55=== modified file 'ubuntuone/syncdaemon/filesystem_notifications.py'
56--- ubuntuone/syncdaemon/filesystem_notifications.py 2011-09-15 21:14:24 +0000
57+++ ubuntuone/syncdaemon/filesystem_notifications.py 2012-02-09 14:42:13 +0000
58@@ -125,6 +125,8 @@
59
60 def eq_push(self, event_name, **event_data):
61 """Sends to EQ the event data, maybe filtering it."""
62+ if event_name == 'FS_DIR_DELETE':
63+ self.handle_dir_delete(event_data['path'])
64 if not self._to_mute.pop(event_name, **event_data):
65 self.monitor.eq.push(event_name, **event_data)
66
67@@ -149,8 +151,6 @@
68 return
69
70 if not self.is_ignored(event.pathname):
71- if evt_name == 'FS_DIR_DELETE':
72- self.handle_dir_delete(event.pathname)
73 self.eq_push(evt_name, path=event.pathname)
74
75 def freeze_begin(self, path):

Subscribers

People subscribed via source and target branches