mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-03-10 22:43:52 +00:00
Enable Windows inotify support.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
1607724c59
commit
67239ffa9c
@ -18,7 +18,8 @@ from allmydata.scripts import backupdb
|
|||||||
class DropUploader(service.MultiService):
|
class DropUploader(service.MultiService):
|
||||||
name = 'drop-upload'
|
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)
|
precondition_abspath(local_dir)
|
||||||
|
|
||||||
service.MultiService.__init__(self)
|
service.MultiService.__init__(self)
|
||||||
@ -30,7 +31,10 @@ class DropUploader(service.MultiService):
|
|||||||
self._dbfile = dbfile
|
self._dbfile = dbfile
|
||||||
|
|
||||||
if inotify is None:
|
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
|
self._inotify = inotify
|
||||||
|
|
||||||
if not self._local_path.exists():
|
if not self._local_path.exists():
|
||||||
@ -52,6 +56,8 @@ class DropUploader(service.MultiService):
|
|||||||
self._uploaded_callback = lambda ign: None
|
self._uploaded_callback = lambda ign: None
|
||||||
|
|
||||||
self._notifier = inotify.INotify()
|
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
|
# 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
|
# possibly-incomplete file before the application has closed it. There should always
|
||||||
|
@ -306,7 +306,8 @@ class Basic(testutil.ReallyEqualMixin, testutil.NonASCIIPathMixin, unittest.Test
|
|||||||
class MockDropUploader(service.MultiService):
|
class MockDropUploader(service.MultiService):
|
||||||
name = 'drop-upload'
|
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)
|
service.MultiService.__init__(self)
|
||||||
self.client = client
|
self.client = client
|
||||||
self.upload_dircap = upload_dircap
|
self.upload_dircap = upload_dircap
|
||||||
|
@ -168,11 +168,6 @@ class RealTest(DropUploadTestMixin, unittest.TestCase):
|
|||||||
"""This is skipped unless both Twisted and the platform support inotify."""
|
"""This is skipped unless both Twisted and the platform support inotify."""
|
||||||
|
|
||||||
def test_drop_upload(self):
|
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.inotify = None # use the appropriate inotify for the platform
|
||||||
self.basedir = "drop_upload.RealTest.test_drop_upload"
|
self.basedir = "drop_upload.RealTest.test_drop_upload"
|
||||||
return self._test()
|
return self._test()
|
||||||
@ -180,3 +175,6 @@ class RealTest(DropUploadTestMixin, unittest.TestCase):
|
|||||||
def notify_close_write(self, path):
|
def notify_close_write(self, path):
|
||||||
# Writing to the file causes the notification.
|
# Writing to the file causes the notification.
|
||||||
pass
|
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."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user