]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Enable Windows inotify support.
authorDaira Hopwood <daira@jacaranda.org>
Tue, 28 Apr 2015 19:58:07 +0000 (20:58 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 28 Dec 2015 16:18:51 +0000 (16:18 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/drop_upload.py
src/allmydata/test/test_client.py
src/allmydata/test/test_drop_upload.py

index 06f2273a8d3340767e0c6d64e8ec2e45c4438ce4..ea561d9f287f720bc452a0f4e4af7c84d7dd6d77 100644 (file)
@@ -18,7 +18,8 @@ from allmydata.scripts import backupdb
 class DropUploader(service.MultiService):
     name = 'drop-upload'
 
-    def __init__(self, client, upload_dircap, local_dir, dbfile, inotify=None):
+    def __init__(self, client, upload_dircap, local_dir, dbfile, inotify=None,
+                 pending_delay=1.0):
         precondition_abspath(local_dir)
 
         service.MultiService.__init__(self)
@@ -32,7 +33,10 @@ class DropUploader(service.MultiService):
         self.is_upload_ready = False
 
         if inotify is None:
-            from twisted.internet import inotify
+            if sys.platform == "win32":
+                from allmydata.windows import inotify
+            else:
+                from twisted.internet import inotify
         self._inotify = inotify
 
         if not self._local_path.exists():
@@ -54,6 +58,8 @@ class DropUploader(service.MultiService):
         self._uploaded_callback = lambda ign: None
 
         self._notifier = inotify.INotify()
+        if hasattr(self._notifier, 'set_pending_delay'):
+            self._notifier.set_pending_delay(pending_delay)
 
         # We don't watch for IN_CREATE, because that would cause us to read and upload a
         # possibly-incomplete file before the application has closed it. There should always
index 2ae2b5850cfc02f364220f8d402551eb60b6a60b..61ede5cdc41d120f9784970a99e335e4fe721dab 100644 (file)
@@ -318,7 +318,8 @@ class Basic(testutil.ReallyEqualMixin, testutil.NonASCIIPathMixin, unittest.Test
         class MockDropUploader(service.MultiService):
             name = 'drop-upload'
 
-            def __init__(self, client, upload_dircap, local_dir, dbfile, inotify=None):
+            def __init__(self, client, upload_dircap, local_dir, dbfile, inotify=None,
+                         pending_delay=1.0):
                 service.MultiService.__init__(self)
                 self.client = client
                 self.upload_dircap = upload_dircap
index 8e871cbc11cf5a4c1f72f2be5cdf23e8e18fdcf9..336cfab100664d17cdfe9c5f6ab2cdf3e59e2444 100644 (file)
@@ -168,11 +168,6 @@ class RealTest(DropUploadTestMixin, unittest.TestCase):
     """This is skipped unless both Twisted and the platform support inotify."""
 
     def test_drop_upload(self):
-        # We should always have runtime.platform.supportsINotify, because we're using
-        # Twisted >= 10.1.
-        if not runtime.platform.supportsINotify():
-            raise unittest.SkipTest("Drop-upload support can only be tested for-real on an OS that supports inotify or equivalent.")
-
         self.inotify = None  # use the appropriate inotify for the platform
         self.basedir = "drop_upload.RealTest.test_drop_upload"
         return self._test()
@@ -180,3 +175,6 @@ class RealTest(DropUploadTestMixin, unittest.TestCase):
     def notify_close_write(self, path):
         # Writing to the file causes the notification.
         pass
+
+if sys.platform != "win32" and not runtime.platform.supportsINotify():
+    RealTest.skip = "Drop-upload support can only be tested for-real on an OS that supports inotify or equivalent."