]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
add partial remote scan implementation
authorDavid Stainton <dstainton415@gmail.com>
Wed, 1 Jul 2015 02:38:19 +0000 (19:38 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Wed, 30 Sep 2015 15:45:22 +0000 (16:45 +0100)
src/allmydata/frontends/magic_folder.py

index 9ad4f44a066fa8d832f3dfbf5493f6610c102cc5..03bad96fbb937c3bcb51ec4ada56a9c0c177f1d7 100644 (file)
@@ -9,7 +9,6 @@ from twisted.python import runtime
 from twisted.application import service
 
 from allmydata.interfaces import IDirectoryNode
-
 from allmydata.util import log
 from allmydata.util.fileutil import abspath_expanduser_unicode, precondition_abspath
 from allmydata.util.encodingutil import listdir_unicode, to_filepath, \
@@ -108,8 +107,32 @@ class MagicFolder(service.MultiService):
         self._notifier.watch(self._local_path, mask=self.mask, callbacks=[self._notify],
                              recursive=True)
 
+
     def _scan_remote_collective(self):
-        return self._collective_dirnode.list()
+        upload_readonly_dircap = self._upload_dirnode.get_readonly_uri()
+        collective_dirmap_d = self._collective_dirnode.list()
+        def do_filter(result):
+            def not_mine(x):
+                return result[x][0].get_readonly_uri() != upload_readonly_dircap
+            others = filter(not_mine, result.keys())
+            return result, others
+        collective_dirmap_d.addCallback(do_filter)
+        def do_scans(result):
+            d = defer.succeed(None)
+            collective_dirmap, others = result
+            for dir_name in others:
+                d.addCallback(self._scan_remote(collective_dirmap[dir_name][0]))
+            return d
+        collective_dirmap_d.addCallback(do_scans)
+        return collective_dirmap_d
+
+    def _scan_remote(self, dirnode):
+        listing_d = dirnode.list()
+        def display_listing(result):
+            return result.keys()
+        listing_d.addCallback(display_listing)
+        # XXX ...
+        return listing_d
         
     def _db_file_is_uploaded(self, childpath):
         """_db_file_is_uploaded returns true if the file was previously uploaded