launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19949
Re: [Merge] lp:~cjwatson/launchpad/uncompressed-indexes into lp:launchpad
Review: Approve code
Diff comments:
>
> === modified file 'lib/lp/archivepublisher/publishing.py'
> --- lib/lp/archivepublisher/publishing.py 2016-01-14 17:00:34 +0000
> +++ lib/lp/archivepublisher/publishing.py 2016-02-04 19:54:30 +0000
> @@ -1000,16 +1021,24 @@
> :param file_name: Filename relative to the parent container directory.
> :return: File contents, or None if the file could not be found.
> """
> + open_func = open
> full_name = os.path.join(self._config.distsroot,
> distroseries_name, file_name)
> if not os.path.exists(full_name):
> - # The file we were asked to write out doesn't exist.
> - # Most likely we have an incomplete archive (E.g. no sources
> - # for a given distroseries). This is a non-fatal issue
> - self.log.debug("Failed to find " + full_name)
> - return None
> + if os.path.exists(full_name + '.gz'):
> + open_func = gzip.open
> + full_name = full_name + '.gz'
> + elif os.path.exists(full_name + '.bz2'):
> + open_func = bz2.BZ2File
> + full_name = full_name + '.bz2'
> + else:
> + # The file we were asked to write out doesn't exist.
> + # Most likely we have an incomplete archive (e.g. no sources
> + # for a given distroseries). This is a non-fatal issue.
> + self.log.debug("Failed to find " + full_name)
> + return None
>
> - with open(full_name, 'r') as in_file:
> + with open_func(full_name) as in_file:
> return in_file.read()
Reading the whole uncompressed file into RAM at once seems like an unnecessary bad idea, but nothing should be fatally large right now.
>
> def deleteArchive(self):
--
https://code.launchpad.net/~cjwatson/launchpad/uncompressed-indexes/+merge/285109
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
References