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):
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
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
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)
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):
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):