← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] lp:~cjwatson/launchpad/archive-unambiguous-files-traversals into lp:launchpad

 

Review: Approve code

I guess we'll find all the clients that match on /+files/ paths.

Diff comments:

> 
> === added file 'lib/lp/soyuz/adapters/proxiedsourcefiles.py'
> --- lib/lp/soyuz/adapters/proxiedsourcefiles.py	1970-01-01 00:00:00 +0000
> +++ lib/lp/soyuz/adapters/proxiedsourcefiles.py	2018-05-04 22:20:39 +0000
> @@ -0,0 +1,37 @@
> +# Copyright 2018 Canonical Ltd.  This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +"""Proxied source files."""
> +
> +from __future__ import absolute_import, print_function, unicode_literals
> +
> +__metaclass__ = type
> +__all__ = [
> +    'ProxiedSourceLibraryFileAlias',
> +    ]
> +
> +from lp.services.librarian.browser import ProxiedLibraryFileAlias
> +from lp.services.librarian.client import url_path_quote
> +from lp.services.webapp.publisher import canonical_url
> +from lp.services.webapp.url import urlappend
> +
> +
> +class ProxiedSourceLibraryFileAlias(ProxiedLibraryFileAlias):
> +    """A `ProxiedLibraryFileAlias` variant that traverses via +sourcefiles.
> +
> +    This can be used to construct unambiguous source file URLs even for
> +    imports from upstream archives without robust historical filename
> +    uniqueness checks.
> +    """
> +
> +    @property
> +    def http_url(self):
> +        if self.context.deleted:
> +            return None
> +
> +        url = canonical_url(self.parent.archive, request=self.request)
> +        url = urlappend(url, '+sourcefiles')
> +        url = urlappend(url, self.parent.source_package_name)
> +        url = urlappend(url, self.parent.source_package_version)
> +        return urlappend(
> +            url, url_path_quote(self.context.filename.encode('utf-8')))

This might be nicer as a urlappend(url, os.path.join(...))



-- 
https://code.launchpad.net/~cjwatson/launchpad/archive-unambiguous-files-traversals/+merge/345118
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.


References