]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Use IN_EXCL_UNLINK.
authorDaira Hopwood <daira@jacaranda.org>
Fri, 29 May 2015 20:39:20 +0000 (21:39 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 29 May 2015 20:43:03 +0000 (21:43 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/drop_upload.py

index a2bd853a79dbe766027a5d922c2a7a366c1e20bd..0b658d6f63092b423dec705de1dcb1374781bb1c 100644 (file)
@@ -83,11 +83,18 @@ class DropUploader(service.MultiService):
         if hasattr(self._notifier, 'set_pending_delay'):
             self._notifier.set_pending_delay(pending_delay)
 
+        # IN_EXCL_UNLINK suppresses events for files that have been unlinked from the watched directory.
+        # The constant is missing from Twisted (see <https://twistedmatrix.com/trac/ticket/7789>) so we
+        # define it here.
+        inotify_IN_EXCL_UNLINK = 0x04000000
+
         # 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
         # be an IN_CLOSE_WRITE after an IN_CREATE (I think).
+        #
+        # IN_ONLY_DIR causes an error if the target path does not reference a directory.
         # TODO: what about IN_MOVE_SELF or IN_UNMOUNT?
-        self.mask = inotify.IN_CLOSE_WRITE | inotify.IN_MOVED_TO | inotify.IN_ONLYDIR
+        self.mask = inotify.IN_CLOSE_WRITE | inotify.IN_MOVED_TO | inotify_IN_EXCL_UNLINK | inotify.IN_ONLYDIR
         self._notifier.watch(self._local_path, mask=self.mask, callbacks=[self._notify],
                              recursive=True)