(Steve Dougherty)
2013-07-30: Fix resolving WoT freenet:// pull URIs. Fix resolving WoT freenet:// pull URIs. The default truster string was being used where a Local_WoT_ID was required. Modify get_truster() to take an explicit truster argument instead of a dictionary, so it's easier to use elsewhere.
diff --git a/infocalypse/__init__.py b/infocalypse/__init__.py --- a/infocalypse/__init__.py +++ b/infocalypse/__init__.py @@ -568,7 +568,7 @@ extensions.wrapfunction(discovery, 'find # wrap the commands -def freenetpathtouri(ui, path, pull=True): +def freenetpathtouri(ui, path, pull=True, repo=None): """ Return a usable request or insert URI. Expects a freenet:// or freenet: protocol to be specified. @@ -588,9 +588,7 @@ def freenetpathtouri(ui, path, pull=True if not path.startswith("USK"): import wot if pull: - cfg = Config.from_ui(ui) - # TODO: Check for ID associated with this repo first. - truster = cfg.defaults['DEFAULT_TRUSTER'] + truster = get_truster(ui, repo) return wot.resolve_pull_uri(ui, path, truster) else: return wot.resolve_push_uri(ui, path) @@ -703,13 +701,16 @@ def freenetclone(orig, *args, **opts): if dest.endswith(".R1") or dest.endswith(".R0"): dest = dest[:-3] + # TODO: source holds the "repo" argument, but the naming is confusing in + # the context of freenetpathtouri(). # check whether to create, pull or copy pulluri, pushuri = None, None if isfreenetpath(source): - pulluri = parse_repo_path(freenetpathtouri(ui, source)) + pulluri = parse_repo_path(freenetpathtouri(ui, source, repo=source)) if isfreenetpath(dest): - pushuri = parse_repo_path(freenetpathtouri(ui, dest, pull=False), + pushuri = parse_repo_path(freenetpathtouri(ui, dest, pull=False, + repo=source), assume_redundancy=True) # decide which infocalypse command to use. diff --git a/infocalypse/commands.py b/infocalypse/commands.py --- a/infocalypse/commands.py +++ b/infocalypse/commands.py @@ -196,7 +196,7 @@ def infocalypse_pull(ui_, repo, **opts): request_uri = get_uri_from_hash(ui_, repo, params, stored_cfg) elif opts['wot']: import wot - truster = get_truster(ui_, repo, opts) + truster = get_truster(ui_, repo, opts['truster']) request_uri = wot.resolve_pull_uri(ui_, opts['wot'], truster) elif opts['uri']: @@ -222,7 +222,7 @@ def infocalypse_pull_request(ui, repo, * "--wot.\n") wot_id, repo_name = opts['wot'].split('/', 1) - from_identity = get_truster(ui, repo, opts) + from_identity = get_truster(ui, repo, opts['truster']) to_identity = WoT_ID(wot_id, from_identity) wot.send_pull_request(ui, repo, from_identity, to_identity, repo_name) @@ -509,22 +509,23 @@ def infocalypse_setupfreemail(ui, repo, import wot # TODO: Here --truster doesn't make sense. There is no trust involved. # TODO: Should this be part of the normal fn-setup? - wot.execute_setup_freemail(ui, get_truster(ui, repo, opts)) + wot.execute_setup_freemail(ui, get_truster(ui, repo, opts['truster'])) -def get_truster(ui, repo, opts): +def get_truster(ui, repo, truster_identifier=None): """ Return a local WoT ID - either one that published this repository or the default. :rtype : Local_WoT_ID """ from wot_id import Local_WoT_ID - if opts['truster']: - return Local_WoT_ID(opts['truster']) + if truster_identifier: + return Local_WoT_ID(truster_identifier) else: - cfg = Config().from_ui(ui) + cfg = Config.from_ui(ui) - # Value is identity ID. + # Value is identity ID, so '@' prefix makes it an identifier with an + # empty nickname. identity = cfg.get_wot_identity(cfg.get_request_uri(repo.root)) if not identity: identity = cfg.defaults['DEFAULT_TRUSTER']