convert stop(_monitoring)

This commit is contained in:
Jean-Paul Calderone 2019-02-25 15:51:44 -05:00
parent 44a8ac8161
commit 28a4a61dab
1 changed files with 25 additions and 13 deletions

View File

@ -632,6 +632,13 @@ START_MONITORING = ActionType(
u"Uploader is beginning to monitor the filesystem for uploadable changes.", u"Uploader is beginning to monitor the filesystem for uploadable changes.",
) )
STOP_MONITORING = ActionType(
u"magic-folder:stop-monitoring",
[_NICKNAME, _DIRECTION],
[],
u"Uploader is terminating filesystem monitoring operation.",
)
class QueueMixin(HookMixin): class QueueMixin(HookMixin):
""" """
@ -945,6 +952,11 @@ class Uploader(QueueMixin):
return d.addActionFinish() return d.addActionFinish()
def stop(self): def stop(self):
action = STOP_MONITORING(
nickname=self._client.nickname,
direction=self._name,
)
with action.context():
self._notifier.stopReading() self._notifier.stopReading()
self._count('dirs_monitored', -1) self._count('dirs_monitored', -1)
if self._periodic_callid: if self._periodic_callid:
@ -954,12 +966,12 @@ class Uploader(QueueMixin):
pass pass
if hasattr(self._notifier, 'wait_until_stopped'): if hasattr(self._notifier, 'wait_until_stopped'):
d = self._notifier.wait_until_stopped() d = DeferredContext(self._notifier.wait_until_stopped())
else: else:
d = defer.succeed(None) d = DeferredContext(defer.succeed(None))
d.addCallback(lambda ignored: QueueMixin.stop(self)) d.addCallback(lambda ignored: QueueMixin.stop(self))
return d return d.addActionFinish()
def start_uploading(self): def start_uploading(self):
self._log("start_uploading") self._log("start_uploading")