From: David Stainton <dstainton415@gmail.com>
Date: Tue, 28 Apr 2015 17:42:44 +0000 (+0100)
Subject: Add twisted inotifier watch upon new directory placement
X-Git-Url: https://git.rkrishnan.org/%5B/simplejson/readonly?a=commitdiff_plain;h=refs%2Fheads%2F2406.otf-objective-2.4;p=tahoe-lafs%2Ftahoe-lafs.git

Add twisted inotifier watch upon new directory placement
---

diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py
index 8d7e47fb..835d0627 100644
--- a/src/allmydata/frontends/drop_upload.py
+++ b/src/allmydata/frontends/drop_upload.py
@@ -69,8 +69,8 @@ class DropUploader(service.MultiService):
         # possibly-incomplete file before the application has closed it. There should always
         # be an IN_CLOSE_WRITE after an IN_CREATE (I think).
         # TODO: what about IN_MOVE_SELF or IN_UNMOUNT?
-        mask = inotify.IN_CLOSE_WRITE | inotify.IN_MOVED_TO | inotify.IN_ONLYDIR
-        self._notifier.watch(self._local_path, mask=mask, callbacks=[self._notify],
+        self.mask = inotify.IN_CLOSE_WRITE | inotify.IN_MOVED_TO | inotify.IN_ONLYDIR
+        self._notifier.watch(self._local_path, mask=self.mask, callbacks=[self._notify],
                              autoAdd=True, recursive=True)
 
     def _check_db_file(self, childpath):
@@ -182,6 +182,7 @@ class DropUploader(service.MultiService):
             return self._parent.add_file(name, u)
 
         def _add_dir(ignore, name):
+            self._notifier.watch(to_filepath(path), mask=self.mask, callbacks=[self._notify], autoAdd=True, recursive=True)
             d2 = self._parent.create_subdirectory(name)
             d2.addCallback(lambda ign: self._log("created subdirectory %r" % (path,)))
             d2.addCallback(lambda ign: self._scan(path))