mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 07:06:41 +00:00
Convert some code to show it off
This commit is contained in:
parent
7d6e36d9c7
commit
f4950cff46
@ -1764,10 +1764,10 @@ class Downloader(QueueMixin, WriteFileMixin):
|
||||
d.addCallback(scan_listing)
|
||||
return d.addActionFinish()
|
||||
|
||||
@eliotutil.log_call_deferred(SCAN_REMOTE_COLLECTIVE.action_type)
|
||||
def _scan_remote_collective(self, scan_self=False):
|
||||
scan_batch = {} # path -> [(filenode, metadata)]
|
||||
with SCAN_REMOTE_COLLECTIVE().context():
|
||||
d = DeferredContext(self._collective_dirnode.list())
|
||||
d = DeferredContext(self._collective_dirnode.list())
|
||||
def scan_collective(dirmap):
|
||||
d2 = DeferredContext(defer.succeed(None))
|
||||
for dir_name in dirmap:
|
||||
@ -1806,26 +1806,26 @@ class Downloader(QueueMixin, WriteFileMixin):
|
||||
self._call_hook(None, 'processed', async=True) # await this maybe-Deferred??
|
||||
|
||||
d.addCallback(_filter_batch_to_deque)
|
||||
return d.addActionFinish()
|
||||
return d.result
|
||||
|
||||
def _scan_delay(self):
|
||||
return self._poll_interval
|
||||
|
||||
@eliotutil.log_call_deferred(PERFORM_SCAN.action_type)
|
||||
@eliotutil.inline_callbacks
|
||||
def _perform_scan(self):
|
||||
with PERFORM_SCAN():
|
||||
try:
|
||||
yield self._scan_remote_collective()
|
||||
self._status_reporter(
|
||||
True, 'Magic folder is working',
|
||||
'Last scan: %s' % self.nice_current_time(),
|
||||
)
|
||||
except Exception as e:
|
||||
write_traceback()
|
||||
self._status_reporter(
|
||||
False, 'Remote scan has failed: %s' % str(e),
|
||||
'Last attempted at %s' % self.nice_current_time(),
|
||||
)
|
||||
try:
|
||||
yield self._scan_remote_collective()
|
||||
self._status_reporter(
|
||||
True, 'Magic folder is working',
|
||||
'Last scan: %s' % self.nice_current_time(),
|
||||
)
|
||||
except Exception as e:
|
||||
write_traceback()
|
||||
self._status_reporter(
|
||||
False, 'Remote scan has failed: %s' % str(e),
|
||||
'Last attempted at %s' % self.nice_current_time(),
|
||||
)
|
||||
|
||||
def _process(self, item):
|
||||
"""
|
||||
|
@ -41,6 +41,7 @@ from .eliotutil import (
|
||||
)
|
||||
from ..util.eliotutil import (
|
||||
inline_callbacks,
|
||||
log_call_deferred,
|
||||
)
|
||||
|
||||
_debug = False
|
||||
@ -523,6 +524,7 @@ class FileOperationsHelper(object):
|
||||
self._inotify = fake_inotify # fixme?
|
||||
self._fake_inotify = inject_events
|
||||
|
||||
@log_call_deferred(action_type=u"fileops:move")
|
||||
def move(self, from_path_u, to_path_u):
|
||||
from_fname = from_path_u
|
||||
to_fname = to_path_u
|
||||
@ -534,6 +536,7 @@ class FileOperationsHelper(object):
|
||||
# self._uploader._notifier.event(to_filepath(from_fname), self._inotify.IN_MOVED_FROM)
|
||||
return d
|
||||
|
||||
@log_call_deferred(action_type=u"fileops:write")
|
||||
def write(self, path_u, contents):
|
||||
fname = path_u
|
||||
if not os.path.exists(fname):
|
||||
@ -546,6 +549,7 @@ class FileOperationsHelper(object):
|
||||
self._maybe_notify(fname, self._inotify.IN_CLOSE_WRITE)
|
||||
return d
|
||||
|
||||
@log_call_deferred(action_type=u"fileops:mkdir")
|
||||
def mkdir(self, path_u):
|
||||
fname = path_u
|
||||
d = self._uploader.set_hook('inotify')
|
||||
@ -553,6 +557,7 @@ class FileOperationsHelper(object):
|
||||
self._maybe_notify(fname, self._inotify.IN_CREATE | self._inotify.IN_ISDIR)
|
||||
return d
|
||||
|
||||
@log_call_deferred(action_type=u"fileops:delete")
|
||||
def delete(self, path_u):
|
||||
fname = path_u
|
||||
d = self._uploader.set_hook('inotify')
|
||||
|
Loading…
Reference in New Issue
Block a user