From 784628e2bda62791652128474ead3fdf3c5dcc04 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Fri, 29 May 2015 21:39:20 +0100 Subject: [PATCH] Use IN_EXCL_UNLINK. Signed-off-by: Daira Hopwood --- src/allmydata/frontends/drop_upload.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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) -- 2.45.2