From: Daira Hopwood Date: Tue, 3 Nov 2015 02:32:41 +0000 (+0000) Subject: Simplify _notify and improve logging. X-Git-Url: https://git.rkrishnan.org/reliability?a=commitdiff_plain;h=1d7d8319de9ce8aec2a027421013843b09b7493e;p=tahoe-lafs%2Ftahoe-lafs.git Simplify _notify and improve logging. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 6d77ceb3..0a5211ae 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -143,16 +143,6 @@ class QueueMixin(HookMixin): print s #open("events", "ab+").write(msg) - def _append_to_deque(self, relpath_u): - self._log("_append_to_deque(%r)" % (relpath_u,)) - if relpath_u in self._pending or magicpath.should_ignore_file(relpath_u): - return - self._deque.append(relpath_u) - self._pending.add(relpath_u) - self._count('objects_queued') - if self.is_ready: - self._clock.callLater(0, self._turn_deque) - def _turn_deque(self): self._log("_turn_deque") if self._stopped: @@ -273,6 +263,7 @@ class Uploader(QueueMixin): def _notify(self, opaque, path, events_mask): self._log("inotify event %r, %r, %r\n" % (opaque, path, ', '.join(self._inotify.humanReadableMask(events_mask)))) + relpath_u = self._get_relpath(path) # We filter out IN_CREATE events not associated with a directory. # Acting on IN_CREATE for files could cause us to read and upload @@ -283,11 +274,21 @@ class Uploader(QueueMixin): if ((events_mask & self._inotify.IN_CREATE) != 0 and (events_mask & self._inotify.IN_ISDIR) == 0): - self._log("ignoring inotify event for creation of file %r\n" % (path,)) + self._log("ignoring event for %r (creation of non-directory)\n" % (relpath_u,)) + return + if relpath_u in self._pending: + self._log("ignoring event for %r (already pending)" % (relpath_u,)) + return + if magicpath.should_ignore_file(relpath_u): + self._log("ignoring event for %r (ignorable path)" % (relpath_u,)) return - relpath_u = self._get_relpath(path) - self._append_to_deque(relpath_u) + self._log("appending %r to deque" % (relpath_u,)) + self._deque.append(relpath_u) + self._pending.add(relpath_u) + self._count('objects_queued') + if self.is_ready: + self._clock.callLater(0, self._turn_deque) def _when_queue_is_empty(self): return defer.succeed(None)