Merge lp:~cjwatson/launchpad/mirror-prober-extra-slashes into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18388
Proposed branch: lp:~cjwatson/launchpad/mirror-prober-extra-slashes
Merge into: lp:launchpad
Diff against target: 55 lines (+11/-4)
1 file modified
lib/lp/registry/scripts/distributionmirror_prober.py (+11/-4)
To merge this branch: bzr merge lp:~cjwatson/launchpad/mirror-prober-extra-slashes
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+324379@code.launchpad.net

Commit message

Remove extra internal slashes from URLs requested by the mirror prober.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/scripts/distributionmirror_prober.py'
2--- lib/lp/registry/scripts/distributionmirror_prober.py 2016-11-11 13:00:06 +0000
3+++ lib/lp/registry/scripts/distributionmirror_prober.py 2017-05-22 09:34:40 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 __metaclass__ = type
10@@ -651,7 +651,7 @@
11 for line in _get_cdimage_file_list().readlines():
12 flavour, seriesname, path, size = line.split('\t')
13 paths = d.setdefault((flavour, seriesname), [])
14- paths.append(path)
15+ paths.append(path.lstrip('/'))
16
17 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
18 paths = []
19@@ -681,12 +681,15 @@
20 publishing time are available on that mirror, giving us an idea of when it
21 was last synced to the main archive.
22 """
23+ base_url = mirror.base_url
24+ if not base_url.endswith('/'):
25+ base_url += '/'
26 packages_paths = mirror.getExpectedPackagesPaths()
27 sources_paths = mirror.getExpectedSourcesPaths()
28 all_paths = itertools.chain(packages_paths, sources_paths)
29 request_manager = RequestManager()
30 for series, pocket, component, path in all_paths:
31- url = "%s/%s" % (mirror.base_url, path)
32+ url = urlparse.urljoin(base_url, path)
33 callbacks = ArchiveMirrorProberCallbacks(
34 mirror, series, pocket, component, url, logfile)
35 unchecked_keys.append(url)
36@@ -710,6 +713,10 @@
37 files for a given series and flavour, then we consider that mirror is
38 actually mirroring that series and flavour.
39 """
40+ base_url = mirror.base_url
41+ if not base_url.endswith('/'):
42+ base_url += '/'
43+
44 # The list of files a mirror should contain will change over time and we
45 # don't want to keep records for files a mirror doesn't need to have
46 # anymore, so we delete all records before start probing. This also fixes
47@@ -730,7 +737,7 @@
48 deferredList = []
49 request_manager = RequestManager()
50 for path in paths:
51- url = '%s/%s' % (mirror.base_url, path)
52+ url = urlparse.urljoin(base_url, path)
53 # Use a RedirectAwareProberFactory because CD mirrors are allowed
54 # to redirect, and we need to cope with that.
55 prober = RedirectAwareProberFactory(url)