← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bug-1544806 into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-1544806 into lp:launchpad.

Commit message:
Fix i18n/Index publishing to use i18n-relative paths. Regressed in r17912.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1544806 in Launchpad itself: "i18n/Index erroneously includes path to each file"
  https://bugs.launchpad.net/launchpad/+bug/1544806

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-1544806/+merge/285821

Fix i18n/Index publishing to use i18n-relative paths.
  
r17912 caused Soyuz to publish i18n/Index using distroseries-relative
paths, but the index lives under i18n so they should be i18n-relative,
eg. "Translation-en" instead of "main/i18n/Translation-en".
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-1544806 into lp:launchpad.
=== modified file 'lib/lp/archivepublisher/publishing.py'
--- lib/lp/archivepublisher/publishing.py	2016-02-05 20:28:29 +0000
+++ lib/lp/archivepublisher/publishing.py	2016-02-12 01:43:06 +0000
@@ -991,7 +991,7 @@
         i18n_index = I18nIndex()
         for i18n_file in sorted(i18n_files):
             hashes = self._readIndexFileHashes(
-                suite, os.path.join(i18n_subpath, i18n_file))
+                suite, i18n_file, subpath=i18n_subpath)
             if hashes is None:
                 continue
             i18n_index.setdefault("SHA1", []).append(hashes["sha1"])
@@ -1004,19 +1004,25 @@
         # Schedule this for inclusion in the Release file.
         all_series_files.add(os.path.join(component, "i18n", "Index"))
 
-    def _readIndexFileHashes(self, distroseries_name, file_name):
+    def _readIndexFileHashes(self, distroseries_name, file_name,
+                             subpath=None):
         """Read an index file and return its hashes.
 
         :param distroseries_name: Distro series name
         :param file_name: Filename relative to the parent container directory.
+        :param subpath: Optional subpath within the distroseries root.
+            Generated indexes will not include this path. If omitted,
+            filenames are assumed to be relative to the distroseries
+            root.
         :return: A dictionary mapping hash field names to dictionaries of
             their components as defined by debian.deb822.Release (e.g.
             {"md5sum": {"md5sum": ..., "size": ..., "name": ...}}), or None
             if the file could not be found.
         """
         open_func = open
-        full_name = os.path.join(self._config.distsroot,
-                                 distroseries_name, file_name)
+        full_name = os.path.join(
+            self._config.distsroot, distroseries_name, subpath or '.',
+            file_name)
         if not os.path.exists(full_name):
             if os.path.exists(full_name + '.gz'):
                 open_func = gzip.open

=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py	2016-02-05 20:28:29 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py	2016-02-12 01:43:06 +0000
@@ -1997,6 +1997,9 @@
                          i18n_index['sha1'][1]['sha1'])
         self.assertEqual(str(len(translation_en_contents)),
                          i18n_index['sha1'][1]['size'])
+        self.assertContentEqual(
+            ['Translation-en', 'Translation-en.gz', 'Translation-en.bz2'],
+            [hash['name'] for hash in i18n_index['sha1']])
 
         # i18n/Index and i18n/Translation-en.bz2 are scheduled for inclusion
         # in Release.  Checksums of the uncompressed version are included


Follow ups