From 0e2c5d330f7c05bcce726cdcedbeebb5d3175961 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Thu, 20 Aug 2015 19:45:49 +0100 Subject: [PATCH] Fix a bug in Downloader._scan_remote that incorrectly skips subsequent files (and drops a Deferred) when local version >= remote version. Also simplify that code and robustify it for the case where the version metadata is missing. Signed-off-by: Daira Hopwood --- src/allmydata/frontends/magic_folder.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index ff77adcb..336d9424 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -459,23 +459,18 @@ class Downloader(QueueMixin): self._download_scan_batch[name] = [(file_node, metadata)] def _scan_remote(self, nickname, dirnode): - listing_d = dirnode.list() + d = dirnode.list() def scan_listing(listing_map): for name in listing_map.keys(): file_node, metadata = listing_map[name] local_version = self._get_local_latest(name) # XXX we might need to convert first? - if local_version is not None: - if local_version >= metadata['version']: - print "local version greater than or equal to remote" - return None - else: - print "local version less than remote" - self._append_to_batch(name, file_node, metadata) - else: + remote_version = metadata.get('version', None) + print "%r has local version %r, remote version %r" % (name, local_version, remote_version) + if local_version is None or remote_version is None or local_version < remote_version: self._append_to_batch(name, file_node, metadata) - listing_d.addCallback(scan_listing) - return listing_d + d.addCallback(scan_listing) + return d def _scan_remote_collective(self): self._download_scan_batch = {} # XXX -- 2.45.2