Merge lp:~mandel/ubuntuone-client/fix-802726 into lp:ubuntuone-client

Proposed by Manuel de la Peña
Status: Merged
Approved by: Natalia Bidart
Approved revision: 1034
Merged at revision: 1032
Proposed branch: lp:~mandel/ubuntuone-client/fix-802726
Merge into: lp:ubuntuone-client
Diff against target: 116 lines (+44/-8)
2 files modified
tests/platform/windows/test_filesystem_notifications.py (+37/-7)
ubuntuone/platform/windows/filesystem_notifications.py (+7/-1)
To merge this branch: bzr merge lp:~mandel/ubuntuone-client/fix-802726
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+66373@code.launchpad.net

Commit message

- Added an extra filtering to ensure that the IN_OPEN|IN_ISDIR masked events do not get to the fsm (LP: #802726).

Description of the change

fixes: lp:802726

Adds an extra filtering to ensure that the IN_OPEN|IN_ISDIR masked events do not get to the fsm.

To post a comment you must log in.
1031. By Manuel de la Peña

Link bug

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Very good!

review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/platform/windows/test_filesystem_notifications.py'
--- tests/platform/windows/test_filesystem_notifications.py 2011-04-01 16:07:13 +0000
+++ tests/platform/windows/test_filesystem_notifications.py 2011-06-30 12:21:13 +0000
@@ -71,7 +71,7 @@
71 FILE_NOTIFY_CHANGE_LAST_ACCESS71 FILE_NOTIFY_CHANGE_LAST_ACCESS
7272
73 def _perform_operations(self, path, mask, auto_add, actions, number_events):73 def _perform_operations(self, path, mask, auto_add, actions, number_events):
74 """Performs the file operations and returns the recorded events."""74 """Perform the file operations and returns the recorded events."""
75 manager = WatchManager()75 manager = WatchManager()
76 manager.add_watch(path, mask, auto_add=auto_add)76 manager.add_watch(path, mask, auto_add=auto_add)
77 handler = TestCaseHandler()77 handler = TestCaseHandler()
@@ -85,6 +85,22 @@
85 notifier.stop()85 notifier.stop()
86 return events86 return events
8787
88 def _perform_timed_operations(self, path, mask, auto_add, actions,
89 time_out):
90 """Perform the file operations and returns the recorded events."""
91 manager = WatchManager()
92 manager.add_watch(path, mask, auto_add=auto_add)
93 handler = TestCaseHandler()
94 notifier = Notifier(manager, handler)
95 # execution the actions
96 actions()
97 # process the recorded events
98 time.sleep(time_out)
99 notifier.process_events()
100 events = handler.processed_events
101 notifier.stop()
102 return events
103
88 def test_file_create(self):104 def test_file_create(self):
89 """Test that the correct event is returned on a file create."""105 """Test that the correct event is returned on a file create."""
90 file_name = os.path.join(self.basedir, 'test_file_create')106 file_name = os.path.join(self.basedir, 'test_file_create')
@@ -368,6 +384,20 @@
368 notifier.stop()384 notifier.stop()
369 self.assertEqual(0, len(handler.processed_events))385 self.assertEqual(0, len(handler.processed_events))
370386
387 def test_open_dir_muted(self):
388 """Test that the opening of dirs is ignored."""
389 dir_name = os.path.join(tempfile.mkdtemp(), 'test_dir_open')
390 # create file before we record
391 os.mkdir(dir_name)
392
393 def open_dir():
394 """Action for the test."""
395 os.startfile(dir_name)
396
397 events = self._perform_timed_operations(self.basedir, self.mask, False,
398 open_dir, 2)
399 self.assertEqual(0, len(events))
400
371401
372class TestWatchManager(MockerTestCase):402class TestWatchManager(MockerTestCase):
373 """Test the watch manager."""403 """Test the watch manager."""
@@ -452,6 +482,8 @@
452 """Test the wd is returned when there is a watch for the path."""482 """Test the wd is returned when there is a watch for the path."""
453 self.manager._wdm = {1: self.watch}483 self.manager._wdm = {1: self.watch}
454 path = 'path'484 path = 'path'
485 self.watch.auto_add
486 self.mocker.result(True)
455 self.watch.path487 self.watch.path
456 self.mocker.result(path)488 self.mocker.result(path)
457 self.mocker.replay()489 self.mocker.replay()
@@ -482,12 +514,12 @@
482 path = 'path'514 path = 'path'
483 self.watch.path515 self.watch.path
484 self.mocker.result(path)516 self.mocker.result(path)
485 self.watch.path517 self.watch.auto_add
486 self.mocker.result(path)518 self.mocker.result(True)
487 self.watch.stop_watching()519 self.watch.exclude_filter = ANY
488 self.mocker.replay()520 self.mocker.replay()
489 self.manager.rm_path(path)521 self.manager.rm_path(path)
490 self.assertEqual(None, self.manager._wdm.get(1))522 self.assertEqual(self.watch, self.manager._wdm.get(1))
491523
492 def test_rm_child_path(self):524 def test_rm_child_path(self):
493 """Test the removal of a child path."""525 """Test the removal of a child path."""
@@ -495,8 +527,6 @@
495 path = 'path'527 path = 'path'
496 self.watch.path528 self.watch.path
497 self.mocker.result(path)529 self.mocker.result(path)
498 self.watch.path
499 self.mocker.result(path)
500 self.watch.auto_add530 self.watch.auto_add
501 self.mocker.result(True)531 self.mocker.result(True)
502 self.watch.exclude_filter = ANY532 self.watch.exclude_filter = ANY
503533
=== modified file 'ubuntuone/platform/windows/filesystem_notifications.py'
--- ubuntuone/platform/windows/filesystem_notifications.py 2011-06-29 20:11:28 +0000
+++ ubuntuone/platform/windows/filesystem_notifications.py 2011-06-30 12:21:13 +0000
@@ -171,6 +171,12 @@
171 self._subdirs.append(path)171 self._subdirs.append(path)
172 return is_dir172 return is_dir
173173
174 def _is_excluded(self, event):
175 """Return if an event is ignored."""
176 return (self.exclude_filter and self.exclude_filter(event)) or\
177 event.mask == IN_OPEN | IN_ISDIR
178
179
174 def _process_events(self):180 def _process_events(self):
175 """Process the events form the queue."""181 """Process the events form the queue."""
176 # we transform the events to be the same as the one in pyinotify182 # we transform the events to be the same as the one in pyinotify
@@ -221,7 +227,7 @@
221 # the exclude filter returns False, that is, the event will not227 # the exclude filter returns False, that is, the event will not
222 # be excluded228 # be excluded
223 self.log.debug('Event is %s.', event)229 self.log.debug('Event is %s.', event)
224 if not self.exclude_filter or not self.exclude_filter(event):230 if not self._is_excluded(event):
225 self.log.debug('Addding event %s to queue.', event)231 self.log.debug('Addding event %s to queue.', event)
226 self.events_queue.put(event)232 self.events_queue.put(event)
227233

Subscribers

People subscribed via source and target branches