Merge lp:~mandel/ubuntuone-client/add-watch-deferred into lp:ubuntuone-client

Proposed by Manuel de la Peña
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 1119
Merged at revision: 1081
Proposed branch: lp:~mandel/ubuntuone-client/add-watch-deferred
Merge into: lp:ubuntuone-client
Prerequisite: lp:~mandel/ubuntuone-client/fix-fsm
Diff against target: 446 lines (+74/-44)
6 files modified
tests/platform/test_filesystem_notifications.py (+40/-20)
tests/syncdaemon/test_vm.py (+15/-11)
ubuntuone/platform/linux/filesystem_notifications.py (+2/-2)
ubuntuone/platform/windows/filesystem_notifications.py (+4/-2)
ubuntuone/syncdaemon/local_rescan.py (+11/-7)
ubuntuone/syncdaemon/volume_manager.py (+2/-2)
To merge this branch: bzr merge lp:~mandel/ubuntuone-client/add-watch-deferred
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+69816@code.launchpad.net

Commit message

Changed add_watch to return a deferred so that we will be waiting for a successful callback before we assume that the watch is running.

Description of the change

Changed add_watch to return a deferred so that we will be waiting for a successful callback before we assume that the watch is running.

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

Merged fix-fsm into add-watch-deferred.

1118. By Manuel de la Peña

Merged fix-fsm into add-watch-deferred.

1119. By Manuel de la Peña

Merged fix-fsm into add-watch-deferred.

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

Looks good!

review: Approve
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Code looks fine, and all tests pass!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/platform/test_filesystem_notifications.py'
--- tests/platform/test_filesystem_notifications.py 2011-07-28 14:51:42 +0000
+++ tests/platform/test_filesystem_notifications.py 2011-07-29 17:35:26 +0000
@@ -239,6 +239,7 @@
239239
240 @skipIfOS('win32', 'There is no reasonable way to know when a file is '240 @skipIfOS('win32', 'There is no reasonable way to know when a file is '
241 + 'opened on windows.')241 + 'opened on windows.')
242 @defer.inlineCallbacks
242 def test_file_open(self):243 def test_file_open(self):
243 """Test receiving the open signal on files."""244 """Test receiving the open signal on files."""
244 testfile = os.path.join(self.root_dir, "foo")245 testfile = os.path.join(self.root_dir, "foo")
@@ -246,15 +247,17 @@
246 self.monitor.add_to_mute_filter("FS_FILE_OPEN", path=testfile)247 self.monitor.add_to_mute_filter("FS_FILE_OPEN", path=testfile)
247 self.monitor.add_to_mute_filter("FS_FILE_CLOSE_NOWRITE", path=testfile)248 self.monitor.add_to_mute_filter("FS_FILE_CLOSE_NOWRITE", path=testfile)
248 self.assertEqual(self._how_many_muted(), 2)249 self.assertEqual(self._how_many_muted(), 2)
249 self.monitor.add_watch(self.root_dir)250 yield self.monitor.add_watch(self.root_dir)
250251
251 # generate the event252 # generate the event
252 open(testfile)253 open(testfile)
253 reactor.callLater(self.timeout - 0.2, self.check_filter)254 reactor.callLater(self.timeout - 0.2, self.check_filter)
254 return self._deferred255 test_result = yield self._deferred
256 defer.returnValue(test_result)
255257
256 @skipIfOS('win32', 'There is no reasonable way to know when a file was '258 @skipIfOS('win32', 'There is no reasonable way to know when a file was '
257 'opened on windows')259 'opened on windows')
260 @defer.inlineCallbacks
258 def test_file_close_nowrite(self):261 def test_file_close_nowrite(self):
259 """Test receiving the close_nowrite signal on files."""262 """Test receiving the close_nowrite signal on files."""
260 testfile = os.path.join(self.root_dir, "foo")263 testfile = os.path.join(self.root_dir, "foo")
@@ -262,13 +265,15 @@
262 fh = open(testfile)265 fh = open(testfile)
263 self.monitor.add_to_mute_filter("FS_FILE_CLOSE_NOWRITE", path=testfile)266 self.monitor.add_to_mute_filter("FS_FILE_CLOSE_NOWRITE", path=testfile)
264 self.assertEqual(self._how_many_muted(), 1)267 self.assertEqual(self._how_many_muted(), 1)
265 self.monitor.add_watch(self.root_dir)268 yield self.monitor.add_watch(self.root_dir)
266269
267 # generate the event270 # generate the event
268 fh.close()271 fh.close()
269 reactor.callLater(self.timeout - 0.2, self.check_filter)272 reactor.callLater(self.timeout - 0.2, self.check_filter)
270 return self._deferred273 test_result = yield self._deferred
274 defer.returnValue(test_result)
271275
276 @defer.inlineCallbacks
272 def test_file_create_close_write(self):277 def test_file_create_close_write(self):
273 """Test receiving the create and close_write signals on files."""278 """Test receiving the create and close_write signals on files."""
274 testfile = os.path.join(self.root_dir, "foo")279 testfile = os.path.join(self.root_dir, "foo")
@@ -276,53 +281,61 @@
276 self.monitor.add_to_mute_filter("FS_FILE_OPEN", path=testfile)281 self.monitor.add_to_mute_filter("FS_FILE_OPEN", path=testfile)
277 self.monitor.add_to_mute_filter("FS_FILE_CLOSE_WRITE", path=testfile)282 self.monitor.add_to_mute_filter("FS_FILE_CLOSE_WRITE", path=testfile)
278 self.assertEqual(self._how_many_muted(), 3)283 self.assertEqual(self._how_many_muted(), 3)
279 self.monitor.add_watch(self.root_dir)284 yield self.monitor.add_watch(self.root_dir)
280285
281 # generate the event286 # generate the event
282 fd = open(testfile, "w")287 fd = open(testfile, "w")
283 fd.write('test')288 fd.write('test')
284 fd.close()289 fd.close()
285 reactor.callLater(self.timeout - 0.2, self.check_filter)290 reactor.callLater(self.timeout - 0.2, self.check_filter)
286 return self._deferred291 test_result = yield self._deferred
292 defer.returnValue(test_result)
287293
294 @defer.inlineCallbacks
288 def test_dir_create(self):295 def test_dir_create(self):
289 """Test receiving the create signal on dirs."""296 """Test receiving the create signal on dirs."""
290 testdir = os.path.join(self.root_dir, "foo")297 testdir = os.path.join(self.root_dir, "foo")
291 self.monitor.add_to_mute_filter("FS_DIR_CREATE", path=testdir)298 self.monitor.add_to_mute_filter("FS_DIR_CREATE", path=testdir)
292 self.assertEqual(self._how_many_muted(), 1)299 self.assertEqual(self._how_many_muted(), 1)
293 self.monitor.add_watch(self.root_dir)300 yield self.monitor.add_watch(self.root_dir)
294301
295 # generate the event302 # generate the event
296 os.mkdir(testdir)303 os.mkdir(testdir)
297 reactor.callLater(self.timeout - 0.2, self.check_filter)304 reactor.callLater(self.timeout - 0.2, self.check_filter)
298 return self._deferred305 test_result = yield self._deferred
306 defer.returnValue(test_result)
299307
308 @defer.inlineCallbacks
300 def test_file_delete(self):309 def test_file_delete(self):
301 """Test the delete signal on a file."""310 """Test the delete signal on a file."""
302 testfile = os.path.join(self.root_dir, "foo")311 testfile = os.path.join(self.root_dir, "foo")
303 open(testfile, "w").close()312 open(testfile, "w").close()
304 self.monitor.add_to_mute_filter("FS_FILE_DELETE", path=testfile)313 self.monitor.add_to_mute_filter("FS_FILE_DELETE", path=testfile)
305 self.assertEqual(self._how_many_muted(), 1)314 self.assertEqual(self._how_many_muted(), 1)
306 self.monitor.add_watch(self.root_dir)315 yield self.monitor.add_watch(self.root_dir)
307316
308 # generate the event317 # generate the event
309 os.remove(testfile)318 os.remove(testfile)
310 reactor.callLater(self.timeout - 0.2, self.check_filter)319 reactor.callLater(self.timeout - 0.2, self.check_filter)
311 return self._deferred320 test_result = yield self._deferred
321 defer.returnValue(test_result)
312322
323 @defer.inlineCallbacks
313 def test_dir_delete(self):324 def test_dir_delete(self):
314 """Test the delete signal on a dir."""325 """Test the delete signal on a dir."""
315 testdir = os.path.join(self.root_dir, "foo")326 testdir = os.path.join(self.root_dir, "foo")
316 os.mkdir(testdir)327 os.mkdir(testdir)
317 self.monitor.add_to_mute_filter("FS_DIR_DELETE", path=testdir)328 self.monitor.add_to_mute_filter("FS_DIR_DELETE", path=testdir)
318 self.assertEqual(self._how_many_muted(), 1)329 self.assertEqual(self._how_many_muted(), 1)
319 self.monitor.add_watch(self.root_dir)330 yield self.monitor.add_watch(self.root_dir)
320331
321 # generate the event332 # generate the event
322 os.rmdir(testdir)333 os.rmdir(testdir)
323 reactor.callLater(self.timeout - 0.2, self.check_filter)334 reactor.callLater(self.timeout - 0.2, self.check_filter)
324 return self._deferred335 test_result = yield self._deferred
336 defer.returnValue(test_result)
325337
338 @defer.inlineCallbacks
326 def test_file_moved_inside(self):339 def test_file_moved_inside(self):
327 """Test the synthesis of the FILE_MOVE event."""340 """Test the synthesis of the FILE_MOVE event."""
328 fromfile = os.path.join(self.root_dir, "foo")341 fromfile = os.path.join(self.root_dir, "foo")
@@ -335,13 +348,15 @@
335 self.monitor.add_to_mute_filter("FS_FILE_MOVE",348 self.monitor.add_to_mute_filter("FS_FILE_MOVE",
336 path_from=fromfile, path_to=tofile)349 path_from=fromfile, path_to=tofile)
337 self.assertEqual(self._how_many_muted(), 1)350 self.assertEqual(self._how_many_muted(), 1)
338 self.monitor.add_watch(self.root_dir)351 yield self.monitor.add_watch(self.root_dir)
339352
340 # generate the event353 # generate the event
341 os.rename(fromfile, tofile)354 os.rename(fromfile, tofile)
342 reactor.callLater(self.timeout - 0.2, self.check_filter)355 reactor.callLater(self.timeout - 0.2, self.check_filter)
343 return self._deferred356 test_result = yield self._deferred
357 defer.returnValue(test_result)
344358
359 @defer.inlineCallbacks
345 def test_dir_moved_inside(self):360 def test_dir_moved_inside(self):
346 """Test the synthesis of the DIR_MOVE event."""361 """Test the synthesis of the DIR_MOVE event."""
347 fromdir = os.path.join(self.root_dir, "foo")362 fromdir = os.path.join(self.root_dir, "foo")
@@ -354,13 +369,15 @@
354 self.monitor.add_to_mute_filter("FS_DIR_MOVE",369 self.monitor.add_to_mute_filter("FS_DIR_MOVE",
355 path_from=fromdir, path_to=todir)370 path_from=fromdir, path_to=todir)
356 self.assertEqual(self._how_many_muted(), 1)371 self.assertEqual(self._how_many_muted(), 1)
357 self.monitor.add_watch(self.root_dir)372 yield self.monitor.add_watch(self.root_dir)
358373
359 # generate the event374 # generate the event
360 os.rename(fromdir, todir)375 os.rename(fromdir, todir)
361 reactor.callLater(self.timeout - 0.2, self.check_filter)376 reactor.callLater(self.timeout - 0.2, self.check_filter)
362 return self._deferred377 test_result = yield self._deferred
378 defer.returnValue(test_result)
363379
380 @defer.inlineCallbacks
364 def test_file_moved_from_conflict(self):381 def test_file_moved_from_conflict(self):
365 """Test the handling of the FILE_MOVE event when source is conflict."""382 """Test the handling of the FILE_MOVE event when source is conflict."""
366 fromfile = os.path.join(self.root_dir, "foo.u1conflict")383 fromfile = os.path.join(self.root_dir, "foo.u1conflict")
@@ -373,13 +390,15 @@
373 self.monitor.add_to_mute_filter("FS_FILE_MOVE",390 self.monitor.add_to_mute_filter("FS_FILE_MOVE",
374 path_from=fromfile, path_to=tofile)391 path_from=fromfile, path_to=tofile)
375 self.assertEqual(self._how_many_muted(), 2)392 self.assertEqual(self._how_many_muted(), 2)
376 self.monitor.add_watch(self.root_dir)393 yield self.monitor.add_watch(self.root_dir)
377394
378 # generate the event395 # generate the event
379 os.rename(fromfile, tofile)396 os.rename(fromfile, tofile)
380 reactor.callLater(self.timeout - 0.2, self.check_filter)397 reactor.callLater(self.timeout - 0.2, self.check_filter)
381 return self._deferred398 test_result = yield self._deferred
399 defer.returnValue(test_result)
382400
401 @defer.inlineCallbacks
383 def test_file_moved_from_partial(self):402 def test_file_moved_from_partial(self):
384 """Test the handling of the FILE_MOVE event when source is partial."""403 """Test the handling of the FILE_MOVE event when source is partial."""
385 fromfile = os.path.join(self.root_dir, "mdid.u1partial.foo")404 fromfile = os.path.join(self.root_dir, "mdid.u1partial.foo")
@@ -390,9 +409,10 @@
390 self.monitor.add_to_mute_filter("FS_FILE_CREATE", path=tofile)409 self.monitor.add_to_mute_filter("FS_FILE_CREATE", path=tofile)
391 self.monitor.add_to_mute_filter("FS_FILE_CLOSE_WRITE", path=tofile)410 self.monitor.add_to_mute_filter("FS_FILE_CLOSE_WRITE", path=tofile)
392 self.assertEqual(self._how_many_muted(), 2)411 self.assertEqual(self._how_many_muted(), 2)
393 self.monitor.add_watch(root_dir)412 yield self.monitor.add_watch(root_dir)
394413
395 # generate the event414 # generate the event
396 os.rename(fromfile, tofile)415 os.rename(fromfile, tofile)
397 reactor.callLater(self.timeout - 0.2, self.check_filter)416 reactor.callLater(self.timeout - 0.2, self.check_filter)
398 return self._deferred417 test_result = yield self._deferred
418 defer.returnValue(test_result)
399419
=== modified file 'tests/syncdaemon/test_vm.py'
--- tests/syncdaemon/test_vm.py 2011-07-28 15:43:05 +0000
+++ tests/syncdaemon/test_vm.py 2011-07-29 17:35:26 +0000
@@ -421,7 +421,7 @@
421 self.main.fs.create(path, share.volume_id, is_dir=True)421 self.main.fs.create(path, share.volume_id, is_dir=True)
422 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))422 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))
423 # add a inotify watch to the dir423 # add a inotify watch to the dir
424 self.main.event_q.add_watch(path)424 yield self.main.event_q.add_watch(path)
425 files = ['a_file', os.path.join('dir', 'file'),425 files = ['a_file', os.path.join('dir', 'file'),
426 os.path.join('dir','subdir','file')]426 os.path.join('dir','subdir','file')]
427 for i, file in enumerate(files):427 for i, file in enumerate(files):
@@ -824,15 +824,17 @@
824 self.assertEquals('fake_share_uuid', share.node_id)824 self.assertEquals('fake_share_uuid', share.node_id)
825 self.assertEquals(None, self.vm.shares.get('share_id_1'))825 self.assertEquals(None, self.vm.shares.get('share_id_1'))
826826
827 @defer.inlineCallbacks
827 def test_remove_watch(self):828 def test_remove_watch(self):
828 """Test for VolumeManager._remove_watch"""829 """Test for VolumeManager._remove_watch"""
829 path = os.path.join(self.root_dir, 'dir')830 path = os.path.join(self.root_dir, 'dir')
830 make_dir(path, recursive=True)831 make_dir(path, recursive=True)
831 self.main.event_q.add_watch(path)832 yield self.main.event_q.add_watch(path)
832 self.assertIn(path, self.main.event_q.monitor._general_watchs)833 self.assertIn(path, self.main.event_q.monitor._general_watchs)
833 self.vm._remove_watch(path)834 self.vm._remove_watch(path)
834 self.assertNotIn(path, self.main.event_q.monitor._general_watchs)835 self.assertNotIn(path, self.main.event_q.monitor._general_watchs)
835836
837 @defer.inlineCallbacks
836 def test_remove_watches(self):838 def test_remove_watches(self):
837 """Test for VolumeManager._remove_watches"""839 """Test for VolumeManager._remove_watches"""
838 dirs = ['dir', os.path.join('dir', 'subdir'), 'emptydir']840 dirs = ['dir', os.path.join('dir', 'subdir'), 'emptydir']
@@ -843,9 +845,9 @@
843 make_dir(path, recursive=True)845 make_dir(path, recursive=True)
844 self.main.fs.create(path, "", is_dir=True)846 self.main.fs.create(path, "", is_dir=True)
845 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))847 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))
846 self.main.event_q.add_watch(path)848 yield self.main.event_q.add_watch(path)
847 # insert the root_dir in the list849 # insert the root_dir in the list
848 self.main.event_q.add_watch(self.root_dir)850 yield self.main.event_q.add_watch(self.root_dir)
849 paths.insert(0, self.root_dir)851 paths.insert(0, self.root_dir)
850 for path in paths:852 for path in paths:
851 self.assertIn(path, self.main.event_q.monitor._general_watchs)853 self.assertIn(path, self.main.event_q.monitor._general_watchs)
@@ -854,13 +856,14 @@
854 for path in paths:856 for path in paths:
855 self.assertNotIn(path, self.main.event_q.monitor._general_watchs)857 self.assertNotIn(path, self.main.event_q.monitor._general_watchs)
856858
859 @defer.inlineCallbacks
857 def test_remove_watches_after_dir_rename(self):860 def test_remove_watches_after_dir_rename(self):
858 """Test for VolumeManager._remove_watches after dir rename."""861 """Test for VolumeManager._remove_watches after dir rename."""
859 path = os.path.join(self.root_dir, 'testit')862 path = os.path.join(self.root_dir, 'testit')
860 os.mkdir(path)863 os.mkdir(path)
861 self.main.fs.create(path, "", is_dir=True)864 self.main.fs.create(path, "", is_dir=True)
862 self.main.fs.set_node_id(path, 'dir_node_id')865 self.main.fs.set_node_id(path, 'dir_node_id')
863 self.main.event_q.add_watch(path)866 yield self.main.event_q.add_watch(path)
864867
865 os.rename(path, path+'.old')868 os.rename(path, path+'.old')
866 # remove the watches869 # remove the watches
@@ -869,13 +872,14 @@
869 self.assertNotIn(path, self.main.event_q.monitor._general_watchs,872 self.assertNotIn(path, self.main.event_q.monitor._general_watchs,
870 'watch should not be present')873 'watch should not be present')
871874
875 @defer.inlineCallbacks
872 def test_delete_fsm_object(self):876 def test_delete_fsm_object(self):
873 """Test for VolumeManager._delete_fsm_object"""877 """Test for VolumeManager._delete_fsm_object"""
874 path = os.path.abspath(os.path.join(self.root_dir, 'dir'))878 path = os.path.abspath(os.path.join(self.root_dir, 'dir'))
875 make_dir(path, recursive=True)879 make_dir(path, recursive=True)
876 self.main.fs.create(path, "", is_dir=True)880 self.main.fs.create(path, "", is_dir=True)
877 self.main.fs.set_node_id(path, 'dir_node_id')881 self.main.fs.set_node_id(path, 'dir_node_id')
878 self.main.event_q.add_watch(path)882 yield self.main.event_q.add_watch(path)
879 self.assertIn(path, self.main.event_q.monitor._general_watchs)883 self.assertIn(path, self.main.event_q.monitor._general_watchs)
880 self.assertTrue(self.main.fs.get_by_path(path), path)884 self.assertTrue(self.main.fs.get_by_path(path), path)
881 # remove the watch885 # remove the watch
@@ -1082,7 +1086,7 @@
1082 self.main.fs.create(path, share.volume_id, is_dir=True)1086 self.main.fs.create(path, share.volume_id, is_dir=True)
1083 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))1087 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))
1084 # add a inotify watch to the dir1088 # add a inotify watch to the dir
1085 self.main.event_q.add_watch(path)1089 yield self.main.event_q.add_watch(path)
1086 files = ['a_file', os.path.join('dir', 'file'),1090 files = ['a_file', os.path.join('dir', 'file'),
1087 os.path.join('dir','subdir','file')]1091 os.path.join('dir','subdir','file')]
1088 for i, file in enumerate(files):1092 for i, file in enumerate(files):
@@ -1207,7 +1211,7 @@
1207 # add a inotify watch to the dirs1211 # add a inotify watch to the dirs
1208 for path, is_dir in paths:1212 for path, is_dir in paths:
1209 if is_dir:1213 if is_dir:
1210 self.main.event_q.add_watch(path)1214 yield self.main.event_q.add_watch(path)
1211 self.assertEquals(len(paths), len(dirs+files)+1, paths)1215 self.assertEquals(len(paths), len(dirs+files)+1, paths)
12121216
1213 # unsubscribe from it1217 # unsubscribe from it
@@ -1420,7 +1424,7 @@
1420 self.main.fs.create(path, udf.volume_id, is_dir=True)1424 self.main.fs.create(path, udf.volume_id, is_dir=True)
1421 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))1425 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))
1422 # add a inotify watch to the dir1426 # add a inotify watch to the dir
1423 self.main.event_q.add_watch(path)1427 yield self.main.event_q.add_watch(path)
1424 files = ['a_file', os.path.join('dir','file'),1428 files = ['a_file', os.path.join('dir','file'),
1425 os.path.join('dir','subdir','file')]1429 os.path.join('dir','subdir','file')]
1426 for i, file in enumerate(files):1430 for i, file in enumerate(files):
@@ -2038,7 +2042,7 @@
2038 self.main.fs.create(path, udf.volume_id, is_dir=True)2042 self.main.fs.create(path, udf.volume_id, is_dir=True)
2039 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))2043 self.main.fs.set_node_id(path, 'dir_node_id'+str(i))
2040 # add a inotify watch to the dir2044 # add a inotify watch to the dir
2041 self.main.event_q.add_watch(path)2045 yield self.main.event_q.add_watch(path)
2042 files = ['a_file', os.path.join('dir','file'),2046 files = ['a_file', os.path.join('dir','file'),
2043 os.path.join('dir','subdir','file')]2047 os.path.join('dir','subdir','file')]
2044 for i, file in enumerate(files):2048 for i, file in enumerate(files):
@@ -2095,7 +2099,7 @@
2095 # add a inotify watch to the dirs2099 # add a inotify watch to the dirs
2096 for path, is_dir in paths:2100 for path, is_dir in paths:
2097 if is_dir:2101 if is_dir:
2098 self.main.event_q.add_watch(path)2102 yield self.main.event_q.add_watch(path)
2099 self.assertEquals(len(paths), len(dirs+files)+1, paths)2103 self.assertEquals(len(paths), len(dirs+files)+1, paths)
21002104
2101 # unsubscribe from it2105 # unsubscribe from it
21022106
=== modified file 'ubuntuone/platform/linux/filesystem_notifications.py'
--- ubuntuone/platform/linux/filesystem_notifications.py 2011-07-27 17:10:57 +0000
+++ ubuntuone/platform/linux/filesystem_notifications.py 2011-07-29 17:35:26 +0000
@@ -457,13 +457,13 @@
457 # not add it if already there457 # not add it if already there
458 if dirpath in w_dict:458 if dirpath in w_dict:
459 self.log.debug("Watch already there for %r", dirpath)459 self.log.debug("Watch already there for %r", dirpath)
460 return False460 return defer.succeed(False)
461461
462 # add the watch!462 # add the watch!
463 self.log.debug("Adding %s inotify watch to %r", w_type, dirpath)463 self.log.debug("Adding %s inotify watch to %r", w_type, dirpath)
464 result = w_manager.add_watch(dirpath, events)464 result = w_manager.add_watch(dirpath, events)
465 w_dict[dirpath] = result[dirpath]465 w_dict[dirpath] = result[dirpath]
466 return True466 return defer.succeed(True)
467467
468 def inotify_watch_fix(self, pathfrom, pathto):468 def inotify_watch_fix(self, pathfrom, pathto):
469 """Fix the path in inotify structures."""469 """Fix the path in inotify structures."""
470470
=== modified file 'ubuntuone/platform/windows/filesystem_notifications.py'
--- ubuntuone/platform/windows/filesystem_notifications.py 2011-07-29 17:35:26 +0000
+++ ubuntuone/platform/windows/filesystem_notifications.py 2011-07-29 17:35:26 +0000
@@ -695,8 +695,10 @@
695 # is also watching it kids695 # is also watching it kids
696 if not self._watch_manager.get_wd(dirpath):696 if not self._watch_manager.get_wd(dirpath):
697 # we need to add a watch which will also watch its kids697 # we need to add a watch which will also watch its kids
698 self._watch_manager.add_watch(dirpath, FILESYSTEM_MONITOR_MASK,698 return self._watch_manager.add_watch(dirpath,
699 auto_add=True)699 FILESYSTEM_MONITOR_MASK,
700 auto_add=True)
701 return defer.succeed(True)
700702
701 def is_frozen(self):703 def is_frozen(self):
702 """Checks if there's something frozen."""704 """Checks if there's something frozen."""
703705
=== modified file 'ubuntuone/syncdaemon/local_rescan.py'
--- ubuntuone/syncdaemon/local_rescan.py 2011-07-27 17:10:57 +0000
+++ ubuntuone/syncdaemon/local_rescan.py 2011-07-29 17:35:26 +0000
@@ -235,6 +235,7 @@
235 self._process_next_queue(None)235 self._process_next_queue(None)
236 return self._previous_deferred236 return self._previous_deferred
237237
238 @defer.inlineCallbacks
238 def _add_watches_to_udf_ancestors(self, volume):239 def _add_watches_to_udf_ancestors(self, volume):
239 """Add a inotify watch to volume's ancestors if it's an UDF."""240 """Add a inotify watch to volume's ancestors if it's an UDF."""
240 added_watches = []241 added_watches = []
@@ -252,10 +253,10 @@
252 if not access(ancestor):253 if not access(ancestor):
253 log_info("Tree broken at path: %r", volume.path)254 log_info("Tree broken at path: %r", volume.path)
254 revert_watches()255 revert_watches()
255 return False256 defer.returnValue(False)
256257
257 log_debug("Adding watch to UDF's ancestor %r", ancestor)258 log_debug("Adding watch to UDF's ancestor %r", ancestor)
258 really_added = self.eq.add_watch(ancestor)259 really_added = yield self.eq.add_watch(ancestor)
259 # only note it for the revert if the watch was not there before260 # only note it for the revert if the watch was not there before
260 if really_added:261 if really_added:
261 added_watches.append(ancestor)262 added_watches.append(ancestor)
@@ -263,10 +264,10 @@
263 # finally, check that UDF is ok in disk264 # finally, check that UDF is ok in disk
264 if not access(volume.path):265 if not access(volume.path):
265 revert_watches()266 revert_watches()
266 return False267 defer.returnValue(False)
267268
268 # all is ok269 # all is ok
269 return True270 defer.returnValue(True)
270271
271 def _process_next_queue(self, _):272 def _process_next_queue(self, _):
272 """Process the next item in the queue, if any."""273 """Process the next item in the queue, if any."""
@@ -280,13 +281,14 @@
280 # more to scan281 # more to scan
281 scan_info = self._queue.pop()282 scan_info = self._queue.pop()
282283
284 @defer.inlineCallbacks
283 def safe_scan():285 def safe_scan():
284 """Scan safely"""286 """Scan safely"""
285 try:287 try:
286 # add watches to UDF ancestors and check UDF is ok288 # add watches to UDF ancestors and check UDF is ok
287 volume = scan_info[0]289 volume = scan_info[0]
288 if isinstance(volume, volume_manager.UDF):290 if isinstance(volume, volume_manager.UDF):
289 udf_ok = self._add_watches_to_udf_ancestors(volume)291 udf_ok = yield self._add_watches_to_udf_ancestors(volume)
290 if not udf_ok:292 if not udf_ok:
291 self._process_next_queue(None)293 self._process_next_queue(None)
292 return294 return
@@ -615,12 +617,13 @@
615 filesdirs[fname] = is_dir, statinfo, changed617 filesdirs[fname] = is_dir, statinfo, changed
616 return filesdirs618 return filesdirs
617619
620 @defer.inlineCallbacks
618 def _scan_one_dir(self, scan_info):621 def _scan_one_dir(self, scan_info):
619 """Gets one dir and compares with fsm."""622 """Gets one dir and compares with fsm."""
620 share, dirpath, udf_mode = scan_info623 share, dirpath, udf_mode = scan_info
621624
622 log_debug("Adding watch to %r", dirpath)625 log_debug("Adding watch to %r", dirpath)
623 self.eq.add_watch(dirpath)626 yield self.eq.add_watch(dirpath)
624627
625 to_later = []628 to_later = []
626 self.eq.freeze_begin(dirpath)629 self.eq.freeze_begin(dirpath)
@@ -698,4 +701,5 @@
698 d.addCallback(filter_delete_events)701 d.addCallback(filter_delete_events)
699 d.addCallback(self.eq.freeze_commit)702 d.addCallback(self.eq.freeze_commit)
700 d.addCallback(control)703 d.addCallback(control)
701 return d704 result = yield d
705 defer.returnValue(result)
702706
=== modified file 'ubuntuone/syncdaemon/volume_manager.py'
--- ubuntuone/syncdaemon/volume_manager.py 2011-07-28 15:43:05 +0000
+++ ubuntuone/syncdaemon/volume_manager.py 2011-07-29 17:35:26 +0000
@@ -943,6 +943,7 @@
943 self.shares[share.volume_id] = share943 self.shares[share.volume_id] = share
944 self.m.event_q.push('VM_SHARE_CHANGED', share_id=share.volume_id)944 self.m.event_q.push('VM_SHARE_CHANGED', share_id=share.volume_id)
945945
946 @defer.inlineCallbacks
946 def _create_share_dir(self, share):947 def _create_share_dir(self, share):
947 """ Creates the share root dir, and set the permissions. """948 """ Creates the share root dir, and set the permissions. """
948 # XXX: verterok: This is going to be moved into fsm949 # XXX: verterok: This is going to be moved into fsm
@@ -953,7 +954,7 @@
953 # add the watch after the mkdir954 # add the watch after the mkdir
954 if share.can_write():955 if share.can_write():
955 self.log.debug('adding inotify watch to: %s', share.path)956 self.log.debug('adding inotify watch to: %s', share.path)
956 self.m.event_q.add_watch(share.path)957 yield self.m.event_q.add_watch(share.path)
957 # if it's a ro share, change the perms958 # if it's a ro share, change the perms
958 if not share.can_write():959 if not share.can_write():
959 set_dir_readonly(share.path)960 set_dir_readonly(share.path)
@@ -1949,4 +1950,3 @@
1949 def _serialize(self, value):1950 def _serialize(self, value):
1950 """Serialize value to string using protocol."""1951 """Serialize value to string using protocol."""
1951 return cPickle.dumps(value.__dict__, protocol=2)1952 return cPickle.dumps(value.__dict__, protocol=2)
1952

Subscribers

People subscribed via source and target branches