From: Daira Hopwood Date: Fri, 29 May 2015 20:39:20 +0000 (+0100) Subject: Use IN_EXCL_UNLINK. X-Git-Url: https://git.rkrishnan.org/pf?a=commitdiff_plain;h=5c3940545f5e0002478a03f291ee17c83025e2b1;p=tahoe-lafs%2Ftahoe-lafs.git Use IN_EXCL_UNLINK. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py index a2bd853a..0b658d6f 100644 --- a/src/allmydata/frontends/drop_upload.py +++ b/src/allmydata/frontends/drop_upload.py @@ -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 ) 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)