]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
fix remote scan procedure
authorDavid Stainton <dstainton415@gmail.com>
Wed, 15 Jul 2015 19:14:12 +0000 (12:14 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 20 Jul 2015 23:48:10 +0000 (00:48 +0100)
src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_magic_folder.py

index 4cdc5752681d776f8b8d698ab133b4c6fe597924..9179ebb701396c98b027804de1bbe31c37376c6f 100644 (file)
@@ -186,25 +186,26 @@ class MagicFolder(service.MultiService):
             collective_dirmap, others_list = result
             for dir_name in others_list:
                 d.addCallback(lambda x, dir_name=dir_name: self._scan_remote(dir_name, collective_dirmap[dir_name][0]))
-                collective_dirmap_d.addCallback(self._filter_scan_batch)
-                collective_dirmap_d.addCallback(self._add_batch_to_download_queue)
+                # XXX todo add errback
             return d
         collective_dirmap_d.addCallback(scan_collective)
+        collective_dirmap_d.addCallback(self._filter_scan_batch)
+        collective_dirmap_d.addCallback(self._add_batch_to_download_queue)
         return collective_dirmap_d
 
     def _add_batch_to_download_queue(self, result):
         self._download_deque.extend(result)
-        self._download_pending.update(map(lambda x: x[1], result)) # XXX x[0] or x[1]?
+        self._download_pending.update(map(lambda x: x[0], result))
 
     def _filter_scan_batch(self, result):
         extension = []
+        max_version_dict = {}
         for name in self._download_scan_batch.keys():
             if name in self._download_pending:
                 continue
-            for item in self._download_scan_batch[name]:
-                (nickname, file_node, metadata) = item
-                if self._should_download(name, metadata['version']):
-                    extension += [(name, file_node, metadata)]
+            name, file_node, metadata = max(self._download_scan_batch[name], key=lambda x: x[2]['version'])
+            if self._should_download(name, metadata['version']):
+                extension += [(name, file_node, metadata)]
         return extension
 
     def _download_file(self, name, file_node):
index 279cffc3de2e5a9043ef101cb5be45f6b21d7fdc..a45ded9ee5f426816a2fbe0ebc55d1c6c63ebd9b 100644 (file)
@@ -125,7 +125,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         def _check_move_empty_tree(res):
             self.mkdir_nonascii(empty_tree_dir)
             d2 = defer.Deferred()
-            self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
+            self.magicfolder.set_processed_callback(d2.callback)
             os.rename(empty_tree_dir, new_empty_tree_dir)
             self.notify(to_filepath(new_empty_tree_dir), self.inotify.IN_MOVED_TO)
             return d2
@@ -151,7 +151,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
 
         def _check_moved_tree_is_watched(res):
             d2 = defer.Deferred()
-            self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
+            self.magicfolder.set_processed_callback(d2.callback)
             fileutil.write(abspath_expanduser_unicode(u"another", base=new_small_tree_dir), "file")
             self.notify(to_filepath(abspath_expanduser_unicode(u"another", base=new_small_tree_dir)), self.inotify.IN_CLOSE_WRITE)
             return d2
@@ -201,7 +201,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
 
         def create_test_file(result):
             d2 = defer.Deferred()
-            self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
+            self.magicfolder.set_processed_callback(d2.callback)
             test_file = abspath_expanduser_unicode(u"what", base=self.local_dir)
             fileutil.write(test_file, "meow")
             self.notify(to_filepath(test_file), self.inotify.IN_CLOSE_WRITE)
@@ -328,7 +328,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         def Alice_wait_for_upload(result):
             print "Alice waits for an upload\n"
             d2 = defer.Deferred()
-            self.alice_magicfolder.set_processed_callback(d2.callback, ignore_count=0)
+            self.alice_magicfolder.set_processed_callback(d2.callback)
             return d2
         d.addCallback(Alice_wait_for_upload)
         def Alice_prepare_for_alice_stats(result):
@@ -342,7 +342,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         def Bob_wait_for_download(result):
             print "Bob waits for a download\n"
             d2 = defer.Deferred()
-            self.bob_magicfolder.set_download_callback(d2.callback, ignore_count=0)
+            self.bob_magicfolder.set_download_callback(d2.callback)
             return d2
         d.addCallback(Bob_wait_for_download)
         def Bob_prepare_for_stats(result):