/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/controllers/download_ui.py

  • Committer: Colin Watson
  • Date: 2020-06-08 09:46:29 UTC
  • mfrom: (498.1.3 no-such-file)
  • Revision ID: cjwatson@canonical.com-20200608094629-ioy9p7q5oj7cl9gb
[r=cjwatson] Hide file ids in loggerhead URLs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import urllib
23
23
 
24
24
from breezy.errors import (
25
 
    NoSuchId,
 
25
    NoSuchFile,
26
26
    NoSuchRevision,
27
27
    )
28
28
from breezy import osutils, urlutils
50
50
        return args
51
51
 
52
52
    def __call__(self, environ, start_response):
53
 
        # /download/<rev_id>/<file_id>/[filename]
 
53
        # /download/<rev_id>/<filename>
54
54
        h = self._history
55
55
        args = self.get_args(environ)
56
56
        if len(args) < 2:
57
57
            raise httpexceptions.HTTPMovedPermanently(
58
58
                self._branch.absolute_url('/changes'))
59
59
        revid = h.fix_revid(args[0])
60
 
        file_id = urlutils.unquote_to_bytes(osutils.safe_utf8(args[1]))
61
60
        try:
62
 
            path, filename, content = h.get_file(file_id, revid)
63
 
        except (NoSuchId, NoSuchRevision):
 
61
            path, filename, content = h.get_file(args[1], revid)
 
62
        except (NoSuchFile, NoSuchRevision):
64
63
            raise httpexceptions.HTTPNotFound()
65
64
        mime_type, encoding = mimetypes.guess_type(filename)
66
65
        if mime_type is None: