From 51e07d5a9af3f54a1d12e2e404874daa54be70d7 Mon Sep 17 00:00:00 2001 From: David Stainton Date: Wed, 15 Jul 2015 13:57:58 -0700 Subject: [PATCH] get rid of terrible diminish cap hack --- src/allmydata/scripts/magic_folder_cli.py | 30 +++-------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/allmydata/scripts/magic_folder_cli.py b/src/allmydata/scripts/magic_folder_cli.py index 498de58a..3ffad476 100644 --- a/src/allmydata/scripts/magic_folder_cli.py +++ b/src/allmydata/scripts/magic_folder_cli.py @@ -7,7 +7,7 @@ from .common import BaseOptions, BasedirOptions, get_aliases from .cli import MakeDirectoryOptions, ListOptions, LnOptions import tahoe_ls, tahoe_mv from allmydata.util import fileutil - +from allmydata import uri INVITE_SEPARATOR = "~" @@ -58,28 +58,6 @@ def create(options): return -1 return 0 -def diminish_readonly(write_cap, node_url): - """ - given a write cap and a node url I will return the corresponding readcap - or I'll return None on failure - """ - list_options = ListOptions() - list_options.where = u"%s" % (write_cap,) - list_options["json"] = True - list_options.aliases = {} - list_options.stdin = StringIO("") - list_options.stdout = StringIO() - list_options.stderr = StringIO() - list_options['node-url'] = node_url - - rc = tahoe_ls.list(list_options) - if rc != 0: - return None - - ls_json = list_options.stdout.getvalue() - readonly_cap = json.loads(ls_json)[1][u"ro_uri"] - return readonly_cap - class InviteOptions(BasedirOptions): nickname = None synopsis = "MAGIC_ALIAS: NICKNAME" @@ -110,15 +88,15 @@ def invite(options): print >>options.stderr, "magic-folder: failed to mkdir\n" return -1 dmd_write_cap = mkdir_options.stdout.getvalue().strip() - dmd_readonly_cap = diminish_readonly(dmd_write_cap, options["node-url"]) + dmd_readonly_cap = unicode(uri.from_string(dmd_write_cap).get_readonly().to_string(), 'utf-8') if dmd_readonly_cap is None: # XXX failure print >>options.stderr, "magic-folder: failed to diminish dmd write cap\n" return -1 magic_write_cap = get_aliases(options["node-directory"])[options.alias] - magic_readonly_cap = diminish_readonly(magic_write_cap, options["node-url"]) - + magic_readonly_cap = unicode(uri.from_string(magic_write_cap).get_readonly().to_string(), 'utf-8') + print "MAGIC READONLY CAP ", magic_readonly_cap # tahoe ln CLIENT_READCAP COLLECTIVE_WRITECAP/NICKNAME ln_options = LnOptions() ln_options["node-url"] = options["node-url"] -- 2.45.2