From 807568e09f26d1b111042de58c91362b2a2f447c Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 28 Feb 2019 20:57:09 -0500 Subject: [PATCH] Log downloads --- src/allmydata/frontends/magic_folder.py | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 7a24c2070..00cf23ba4 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -1110,6 +1110,13 @@ PROCESS_ITEM = ActionType( u"A path which was found wanting of an update is receiving an update.", ) +DOWNLOAD_BEST_VERSION = ActionType( + u"magic-folder:download-best-version", + [], + [], + u"The content of a file in the Magic Folder is being downloaded.", +) + class Uploader(QueueMixin): def __init__(self, client, local_path_u, db, upload_dirnode, pending_delay, clock): @@ -1958,14 +1965,19 @@ class Downloader(QueueMixin, WriteFileMixin): if item.metadata.get('deleted', False): d.addCallback(lambda ign: self._rename_deleted_file(abspath_u)) else: - d.addCallback(lambda ign: item.file_node.download_best_version(progress=item.progress)) - d.addCallback( - lambda contents: self._write_downloaded_file( - self._local_path_u, abspath_u, contents, - is_conflict=is_conflict, - mtime=item.metadata.get('user_mtime', item.metadata.get('tahoe', {}).get('linkmotime')), - ) - ) + @eliotutil.inline_callbacks + def download_best_version(ignored): + with DOWNLOAD_BEST_VERSION(): + contents = yield item.file_node.download_best_version(progress=item.progress) + defer.returnValue( + self._write_downloaded_file( + self._local_path_u, abspath_u, contents, + is_conflict=is_conflict, + mtime=item.metadata.get('user_mtime', item.metadata.get('tahoe', {}).get('linkmotime')), + ) + ) + + d.addCallback(download_best_version) d.addCallback(do_update_db) d.addErrback(failed)