← Back to team overview

launchpad-reviewers team mailing list archive

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

 

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

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #522800 Broken link to .orig.tar.gz in PPA package details page (404)
  https://bugs.launchpad.net/bugs/522800


Archive.getFileByName currently doesn't care if the file it returns is expired. That isn't excellent, since an expired file is just about useless. This branch fixes it to only return unexpired files, fixing bug #522800. It also happens to fix bug #687662, a 10.12 regression that was just discovered.
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-522800-getFileByName/+merge/43159
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-522800-getFileByName into lp:launchpad.
=== modified file 'lib/lp/soyuz/doc/archive-files.txt'
--- lib/lp/soyuz/doc/archive-files.txt	2010-10-18 22:24:59 +0000
+++ lib/lp/soyuz/doc/archive-files.txt	2010-12-09 04:41:23 +0000
@@ -82,6 +82,22 @@
     >>> libraryfile == orig_tar_gz
     True
 
+If the file has been expired from the librarian, it is no longer returned.
+
+    >>> from zope.security.proxy import removeSecurityProxy
+    >>> removeSecurityProxy(libraryfile).content = None
+    >>> cprov.archive.getFileByName('test-pkg_1.0.orig.tar.gz')
+    Traceback (most recent call last):
+    ...
+    NotFoundError: 'test-pkg_1.0.orig.tar.gz'
+
+If we add a new file with that name, the new file is returned.
+
+    >>> new = test_publisher.addMockFile('test-pkg_1.0.orig.tar.gz')
+    >>> unused = test_source.sourcepackagerelease.addFile(new)
+    >>> cprov.archive.getFileByName('test-pkg_1.0.orig.tar.gz') == new
+    True
+
 Adding and retrieving a source diff.
 
     >>> diff_gz = test_publisher.addMockFile('test-pkg_1.0.diff.gz')

=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py	2010-12-03 17:35:33 +0000
+++ lib/lp/soyuz/model/archive.py	2010-12-09 04:41:23 +0000
@@ -1311,6 +1311,7 @@
 
         base_clauses = (
             LibraryFileAlias.filename == filename,
+            LibraryFileAlias.content != None,
             )
 
         if re_issource.match(filename):