]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Flush handling WIP. 1431.magic-folder-windows.1
authorDaira Hopwood <daira@jacaranda.org>
Tue, 27 Oct 2015 13:58:37 +0000 (13:58 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 27 Oct 2015 14:48:17 +0000 (14:48 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/test/test_magic_folder.py

index f8e18e60d09a76e4f6d8b06f8f42559db954e5f8..c9e6f5e2714e5f8a7fbe3664c873476c19ba9070 100644 (file)
@@ -155,6 +155,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
             self.mkdir_nonascii(small_tree_dir)
             what_path = abspath_expanduser_unicode(u"what", base=small_tree_dir)
             fileutil.write(what_path, "say when")
+            self.notify(to_filepath(what_path), self.inotify.IN_CLOSE_WRITE, flush=False)
             os.rename(small_tree_dir, new_small_tree_dir)
             self.notify(to_filepath(new_small_tree_dir), self.inotify.IN_MOVED_TO)
 
@@ -621,10 +622,9 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
                 f.close()
             if temporary and sys.platform == "win32":
                 os.unlink(path_u)
-                self.notify(path, self.inotify.IN_DELETE)
+                self.notify(path, self.inotify.IN_DELETE, flush=False)
             event_mask = self.inotify.IN_CLOSE_WRITE
 
-        fileutil.flush_volume(path_u)
         self.notify(path, event_mask)
         encoded_name_u = magicpath.path2magic(name_u)
 
@@ -715,7 +715,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         def notify_bob_moved(ign):
             d0 = self.bob_magicfolder.uploader.set_hook('processed')
             p = abspath_expanduser_unicode(u"file1", base=self.bob_magicfolder.uploader._local_path_u)
-            self.notify(to_filepath(p), self.inotify.IN_MOVED_FROM, magic=self.bob_magicfolder)
+            self.notify(to_filepath(p), self.inotify.IN_MOVED_FROM, magic=self.bob_magicfolder, flush=False)
             self.notify(to_filepath(p + u'.backup'), self.inotify.IN_MOVED_TO, magic=self.bob_magicfolder)
             bob_clock.advance(0)
             return d0
@@ -802,10 +802,11 @@ class MockTest(MagicFolderTestMixin, unittest.TestCase):
         self.inotify = fake_inotify
         self.patch(magic_folder, 'get_inotify_module', lambda: self.inotify)
 
-    def notify(self, path, mask, magic=None):
+    def notify(self, path, mask, magic=None, flush=True):
         if magic is None:
             magic = self.magicfolder
         magic.uploader._notifier.event(path, mask)
+        # no flush for the mock test.
 
     def test_errors(self):
         self.set_up_grid()
@@ -892,9 +893,11 @@ class RealTest(MagicFolderTestMixin, unittest.TestCase):
         MagicFolderTestMixin.setUp(self)
         self.inotify = magic_folder.get_inotify_module()
 
-    def notify(self, path, mask, **kw):
+    def notify(self, path, mask, magic=None, flush=True):
         # Writing to the filesystem causes the notification.
-        pass
+        # However, flushing filesystem buffers may be necessary on Windows.
+        if flush:
+            fileutil.flush_volume(path)
 
 try:
     magic_folder.get_inotify_module()