convert _notify

This commit is contained in:
Jean-Paul Calderone 2019-02-25 16:08:59 -05:00
parent bfb039c6c6
commit c3e50a4536
2 changed files with 13 additions and 8 deletions

View File

@ -685,6 +685,12 @@ SCAN = ActionType(
u"A brute-force scan of a subset of the local directory is being performed.",
)
NOTIFIED = ActionType(
u"magic-folder:notified",
[PATH, _NICKNAME, _DIRECTION],
[],
u"Magic-Folder received a notification of a local filesystem change for a certain path.",
)
class QueueMixin(HookMixin):
"""
@ -1080,13 +1086,11 @@ class Uploader(QueueMixin):
return relpath_u in self._pending
def _notify(self, opaque, path, events_mask):
# Twisted doesn't seem to do anything if our callback throws
# an error, so...
with NOTIFIED(path=path, **self._log_fields):
try:
return self._real_notify(opaque, path, events_mask)
except Exception as e:
self._log(u"error calling _real_notify: {}".format(e))
twlog.err(Failure(), "Error calling _real_notify")
except Exception:
write_traceback()
def _real_notify(self, opaque, path, events_mask):
self._log("inotify event %r, %r, %r\n" % (opaque, path, ', '.join(self._inotify.humanReadableMask(events_mask))))

View File

@ -1789,7 +1789,8 @@ class SingleMagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Reall
# pending callbacks including the exception are processed
# before we flush the errors.
yield task.deferLater(reactor, 0, lambda: None)
errors = self.flushLoggedErrors(BadStuff)
errors = self.eliot_logger.flushTracebacks(BadStuff)
# it seems on Windows the "RealTest" variant only produces 1
# notification for some reason..
self.assertTrue(len(errors) >= 1)