# TODO: allow a path rather than a cap URI.
self._upload_dirnode = self._client.create_node_from_uri(upload_dircap)
+ if collective_dircap != "":
+ # XXX this condition used for some unit tests
+ self._collective_dirnode = self._client.create_node_from_uri(collective_dircap)
+ if not IDirectoryNode.providedBy(self._collective_dirnode):
+ raise AssertionError("The URI in 'private/collective_dircap' does not refer to a directory.")
+ if self._collective_dirnode.is_unknown() or not self._collective_dirnode.is_readonly():
+ raise AssertionError("The URI in 'private/collective_dircap' is not a readonly cap to a directory.")
+
if not IDirectoryNode.providedBy(self._upload_dirnode):
raise AssertionError("The URI in 'private/magic_folder_dircap' does not refer to a directory.")
if self._upload_dirnode.is_unknown() or self._upload_dirnode.is_readonly():
self._notifier.watch(self._local_path, mask=self.mask, callbacks=[self._notify],
recursive=True)
+ def _scan_remote_collective(self):
+ return self._collective_dirnode.list()
+
def _db_file_is_uploaded(self, childpath):
"""_db_file_is_uploaded returns true if the file was previously uploaded
"""
self.failUnless(IDirectoryNode.providedBy(n))
self.upload_dirnode = n
self.upload_dircap = n.get_uri()
- self.collective_dircap = "abc123"
+ self.collective_dircap = ""
def _create_magicfolder(self, ign):
dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.basedir)
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
return d
+ def test_remote_scan(self):
+ self.set_up_grid()
+ self.local_dir = abspath_expanduser_unicode(self.unicode_or_fallback(u"l\u00F8cal_dir", u"local_dir"),
+ base=self.basedir)
+ self.mkdir_nonascii(self.local_dir)
+ self.client = self.g.clients[0]
+ self.stats_provider = self.client.stats_provider
+ d = self.create_invite_join_magic_folder(u"Alice", self.local_dir)
+ d.addCallback(self._create_magicfolder)
+ d.addCallback(lambda x: self.magicfolder._scan_remote_collective())
+ def display_list(results):
+ print "LIST ", results
+ d.addCallback(display_list)
+ d.addBoth(self._cleanup)
+ return d
+
class MockTest(MagicFolderTestMixin, unittest.TestCase):
"""This can run on any platform, and even if twisted.internet.inotify can't be imported."""