← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/mirror-prober-extra-slashes into lp:launchpad.

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

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1692347 in Launchpad itself: "Extra slashes causing mirror probe to fail"
  https://bugs.launchpad.net/launchpad/+bug/1692347

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/mirror-prober-extra-slashes/+merge/324379
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/mirror-prober-extra-slashes into lp:launchpad.
=== modified file 'lib/lp/registry/scripts/distributionmirror_prober.py'
--- lib/lp/registry/scripts/distributionmirror_prober.py	2016-11-11 13:00:06 +0000
+++ lib/lp/registry/scripts/distributionmirror_prober.py	2017-05-22 08:59:53 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -651,7 +651,7 @@
     for line in _get_cdimage_file_list().readlines():
         flavour, seriesname, path, size = line.split('\t')
         paths = d.setdefault((flavour, seriesname), [])
-        paths.append(path)
+        paths.append(path.lstrip('/'))
 
     ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
     paths = []
@@ -686,7 +686,7 @@
     all_paths = itertools.chain(packages_paths, sources_paths)
     request_manager = RequestManager()
     for series, pocket, component, path in all_paths:
-        url = "%s/%s" % (mirror.base_url, path)
+        url = urlparse.urljoin(mirror.base_url, path)
         callbacks = ArchiveMirrorProberCallbacks(
             mirror, series, pocket, component, url, logfile)
         unchecked_keys.append(url)
@@ -730,7 +730,7 @@
         deferredList = []
         request_manager = RequestManager()
         for path in paths:
-            url = '%s/%s' % (mirror.base_url, path)
+            url = urlparse.urljoin(mirror.base_url, path)
             # Use a RedirectAwareProberFactory because CD mirrors are allowed
             # to redirect, and we need to cope with that.
             prober = RedirectAwareProberFactory(url)


Follow ups