Merge lp:~julian-edwards/launchpad/upload-file-conflict-bug-663562 into lp:launchpad

Proposed by Julian Edwards on 2010-11-30
Status: Merged
Approved by: Julian Edwards on 2010-11-30
Approved revision: no longer in the source branch.
Merged at revision: 12009
Proposed branch: lp:~julian-edwards/launchpad/upload-file-conflict-bug-663562
Merge into: lp:launchpad
Diff against target: 61 lines (+29/-2)
2 files modified
lib/lp/archiveuploader/dscfile.py (+3/-2)
lib/lp/archiveuploader/tests/test_ppauploadprocessor.py (+26/-0)
To merge this branch: bzr merge lp:~julian-edwards/launchpad/upload-file-conflict-bug-663562
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve on 2010-11-30
Review via email: mp+42264@code.launchpad.net

Commit message

When the upload processor looking up files, make sure it doen't just look up ones that are not marked as removed so that people cannot later re-upload the same file with different contents.

Description of the change

= Summary =
When the upload processor looking up files, make sure we don't just look up
ones that are not marked as removed.

== Proposed fix ==
Currently the upload processor is only looking up file ancestry where the file
has not been removed from disk, by virtue of using the SQL view
SourcePackageFilePublishing. This should not be allowed to happen because
once a file is uploaded with certain contents, those contents should never
change.

== Implementation details ==
The call to IDistribution.getFileByName is replaced with
IArchive.getFileByName which does the right thing. The context archive can be
None, so that's taken care of too.

== Tests ==
bin/test -cvv test_ppauploadprocessor test_conflicting_deleted_orig_file

To post a comment you must log in.
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archiveuploader/dscfile.py'
2--- lib/lp/archiveuploader/dscfile.py 2010-11-05 14:17:11 +0000
3+++ lib/lp/archiveuploader/dscfile.py 2010-11-30 16:16:46 +0000
4@@ -430,11 +430,12 @@
5 else:
6 archives = [self.policy.archive]
7
8+ archives = [archive for archive in archives if archive is not None]
9+
10 library_file = None
11 for archive in archives:
12 try:
13- library_file = self.policy.distro.getFileByName(
14- filename, source=True, binary=False, archive=archive)
15+ library_file = archive.getFileByName(filename)
16 self.logger.debug(
17 "%s found in %s" % (filename, archive.displayname))
18 return library_file, archive
19
20=== modified file 'lib/lp/archiveuploader/tests/test_ppauploadprocessor.py'
21--- lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2010-11-10 23:42:37 +0000
22+++ lib/lp/archiveuploader/tests/test_ppauploadprocessor.py 2010-11-30 16:16:46 +0000
23@@ -18,6 +18,7 @@
24 from zope.security.proxy import removeSecurityProxy
25
26 from canonical.config import config
27+from canonical.database.constants import UTC_NOW
28 from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
29 from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
30 from canonical.launchpad.testing.fakepackager import FakePackager
31@@ -1113,6 +1114,31 @@
32 self.uploadprocessor.last_processed_upload.queue_root.status,
33 PackageUploadStatus.DONE)
34
35+ def test_conflicting_deleted_orig_file(self):
36+ # Uploading a conflicting orig file should be disallowed even if
37+ # the existing one was deleted from disk.
38+ upload_dir = self.queueUpload("bar_1.0-1-ppa-orig", "~name16/ubuntu")
39+ self.processUpload(self.uploadprocessor, upload_dir)
40+ self.assertEqual(
41+ self.uploadprocessor.last_processed_upload.queue_root.status,
42+ PackageUploadStatus.DONE)
43+
44+ # Delete the published file.
45+ [bar_src] = self.name16.archive.getPublishedSources(name="bar")
46+ bar_src.requestDeletion(self.name16)
47+ bar_src.dateremoved = UTC_NOW
48+ self.layer.txn.commit()
49+
50+ # bar_1.0-3 contains an orig file of the same version with
51+ # different contents than the one we previously uploaded.
52+ upload_dir = self.queueUpload("bar_1.0-3", "~name16/ubuntu")
53+ self.processUpload(self.uploadprocessor, upload_dir)
54+ self.assertTrue(
55+ self.uploadprocessor.last_processed_upload.is_rejected)
56+ self.assertIn(
57+ 'File bar_1.0.orig.tar.gz already exists in ',
58+ self.uploadprocessor.last_processed_upload.rejection_message)
59+
60 def test30QuiltMultipleReusedOrigs(self):
61 """Official orig*.tar.* can be reused for PPA uploads.
62