Merge lp:~wgrant/launchpad/de-view-publisher into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 18209
Proposed branch: lp:~wgrant/launchpad/de-view-publisher
Merge into: lp:launchpad
Diff against target: 700 lines (+99/-284)
10 files modified
lib/lp/archivepublisher/deathrow.py (+7/-7)
lib/lp/archivepublisher/model/ftparchive.py (+31/-20)
lib/lp/archivepublisher/tests/deathrow.txt (+4/-4)
lib/lp/archivepublisher/tests/test_deathrow.py (+6/-6)
lib/lp/archivepublisher/tests/test_ftparchive.py (+3/-3)
lib/lp/soyuz/configure.zcml (+0/-22)
lib/lp/soyuz/doc/publishing.txt (+14/-23)
lib/lp/soyuz/interfaces/publishing.py (+2/-69)
lib/lp/soyuz/model/publishing.py (+31/-129)
lib/lp/soyuz/tests/test_publishing.py (+1/-1)
To merge this branch: bzr merge lp:~wgrant/launchpad/de-view-publisher
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+306688@code.launchpad.net

Commit message

Abolish {Source,Binary}PackageFilePublishing.

Description of the change

Abolish {Source,Binary}PackageFilePublishing.

Two places used the views: ftparchive file list generation (source half rewritten to use a faster direct query, binary half already avoided the view) and xPPH.files (now just returns the SPRF/BPR, and callsites get publication info from... the publication).

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

A quick lint pass would be nice, but otherwise this looks like a very nice simplification. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archivepublisher/deathrow.py'
2--- lib/lp/archivepublisher/deathrow.py 2012-08-17 11:15:35 +0000
3+++ lib/lp/archivepublisher/deathrow.py 2016-10-02 12:40:36 +0000
4@@ -223,16 +223,16 @@
5 See `canRemove` for more information.
6 """
7 for pub_file in pub_record.files:
8- filename = pub_file.libraryfilealiasfilename
9- file_md5 = pub_file.libraryfilealias.content.md5
10+ filename = pub_file.libraryfile.filename
11+ file_md5 = pub_file.libraryfile.content.md5
12
13 self.logger.debug("Checking %s (%s)" % (filename, file_md5))
14
15 # Calculating the file path in pool.
16 pub_file_details = (
17- pub_file.libraryfilealiasfilename,
18- pub_file.sourcepackagename,
19- pub_file.componentname,
20+ pub_file.libraryfile.filename,
21+ pub_record.source_package_name,
22+ pub_record.component_name,
23 )
24 file_path = self.diskpool.pathFor(*pub_file_details)
25
26@@ -243,7 +243,7 @@
27 if (filename, file_md5) in considered_files:
28 self.logger.debug("Already verified.")
29 if file_path in condemned_files:
30- condemned_records.add(pub_file.publishing_record)
31+ condemned_records.add(pub_record)
32 continue
33 considered_files.add((filename, file_md5))
34
35@@ -255,7 +255,7 @@
36 # Update local containers, in preparation to file removal.
37 details.setdefault(file_path, pub_file_details)
38 condemned_files.add(file_path)
39- condemned_records.add(pub_file.publishing_record)
40+ condemned_records.add(pub_record)
41
42 # Check source and binary publishing records.
43 for pub_record in condemned_source_files:
44
45=== modified file 'lib/lp/archivepublisher/model/ftparchive.py'
46--- lib/lp/archivepublisher/model/ftparchive.py 2016-04-05 02:07:48 +0000
47+++ lib/lp/archivepublisher/model/ftparchive.py 2016-10-02 12:40:36 +0000
48@@ -36,10 +36,12 @@
49 from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
50 from lp.soyuz.model.component import Component
51 from lp.soyuz.model.distroarchseries import DistroArchSeries
52-from lp.soyuz.model.files import BinaryPackageFile
53+from lp.soyuz.model.files import (
54+ BinaryPackageFile,
55+ SourcePackageReleaseFile,
56+ )
57 from lp.soyuz.model.publishing import (
58 BinaryPackagePublishingHistory,
59- SourcePackageFilePublishing,
60 SourcePackagePublishingHistory,
61 )
62 from lp.soyuz.model.section import Section
63@@ -562,19 +564,31 @@
64
65 :return: a `ResultSet` with the source files information tuples.
66 """
67- store = IStore(SourcePackagePublishingHistory)
68- result_set = store.using(SourcePackageFilePublishing).find(
69- (SourcePackageFilePublishing.sourcepackagename,
70- SourcePackageFilePublishing.libraryfilealiasfilename,
71- SourcePackageFilePublishing.componentname),
72- SourcePackageFilePublishing.distribution == self.distro,
73- SourcePackageFilePublishing.archive == self.publisher.archive,
74- SourcePackageFilePublishing.distroseriesname == distroseries.name,
75- SourcePackageFilePublishing.pocket == pocket,
76- SourcePackageFilePublishing.publishingstatus ==
77- PackagePublishingStatus.PUBLISHED)
78+ columns = (
79+ SourcePackageName.name,
80+ LibraryFileAlias.filename,
81+ Component.name,
82+ )
83+ join_conditions = [
84+ SourcePackageReleaseFile.sourcepackagereleaseID ==
85+ SourcePackagePublishingHistory.sourcepackagereleaseID,
86+ SourcePackageName.id ==
87+ SourcePackagePublishingHistory.sourcepackagenameID,
88+ LibraryFileAlias.id == SourcePackageReleaseFile.libraryfileID,
89+ Component.id == SourcePackagePublishingHistory.componentID,
90+ ]
91+ select_conditions = [
92+ SourcePackagePublishingHistory.archive == self.publisher.archive,
93+ SourcePackagePublishingHistory.distroseriesID == distroseries.id,
94+ SourcePackagePublishingHistory.pocket == pocket,
95+ SourcePackagePublishingHistory.status ==
96+ PackagePublishingStatus.PUBLISHED,
97+ ]
98
99- return result_set.order_by(Desc(SourcePackageFilePublishing.id))
100+ result_set = IStore(SourcePackageRelease).find(
101+ columns, *(join_conditions + select_conditions))
102+ return result_set.order_by(
103+ LibraryFileAlias.filename, SourcePackageReleaseFile.id)
104
105 def getBinaryFiles(self, distroseries, pocket):
106 """Fetch publishing information about all published binary files.
107@@ -599,16 +613,13 @@
108 BinaryPackageFile.binarypackagereleaseID ==
109 BinaryPackagePublishingHistory.binarypackagereleaseID,
110 BinaryPackageBuild.id == BinaryPackageRelease.buildID,
111- SourcePackageRelease.id ==
112- BinaryPackageBuild.source_package_release_id,
113- SourcePackageName.id == SourcePackageRelease.sourcepackagenameID,
114+ SourcePackageName.id == BinaryPackageBuild.source_package_name_id,
115 LibraryFileAlias.id == BinaryPackageFile.libraryfileID,
116 DistroArchSeries.id ==
117 BinaryPackagePublishingHistory.distroarchseriesID,
118 Component.id == BinaryPackagePublishingHistory.componentID,
119 ]
120 select_conditions = [
121- BinaryPackagePublishingHistory.dateremoved == None,
122 DistroArchSeries.distroseriesID == distroseries.id,
123 BinaryPackagePublishingHistory.archive == self.publisher.archive,
124 BinaryPackagePublishingHistory.pocket == pocket,
125@@ -621,10 +632,10 @@
126 BinaryPackageRelease.binpackageformat
127 != BinaryPackageFormat.DDEB)
128
129- result_set = IStore(SourcePackageRelease).find(
130+ result_set = IStore(BinaryPackageRelease).find(
131 columns, *(join_conditions + select_conditions))
132 return result_set.order_by(
133- BinaryPackagePublishingHistory.id, BinaryPackageFile.id)
134+ LibraryFileAlias.filename, BinaryPackageFile.id)
135
136 def generateFileLists(self, fullpublish=False):
137 """Collect currently published FilePublishings and write filelists."""
138
139=== modified file 'lib/lp/archivepublisher/tests/deathrow.txt'
140--- lib/lp/archivepublisher/tests/deathrow.txt 2011-04-05 08:28:30 +0000
141+++ lib/lp/archivepublisher/tests/deathrow.txt 2016-10-02 12:40:36 +0000
142@@ -202,12 +202,12 @@
143 ... for pub_file in pub.files:
144 ... for pub_file in pub.files:
145 ... file_path = quiet_disk_pool.pathFor(
146- ... pub_file.componentname.encode('utf-8'),
147- ... pub_file.sourcepackagename.encode('utf8'),
148- ... pub_file.libraryfilealiasfilename.encode('utf-8')
149+ ... pub.component.name.encode('utf-8'),
150+ ... pub.source_package_name.encode('utf8'),
151+ ... pub_file.libraryfile.filename.encode('utf-8')
152 ... )
153 ... unique_file_paths.add(file_path)
154- ... pub_file.publish(quiet_disk_pool, BufferLogger())
155+ ... pub.publish(quiet_disk_pool, BufferLogger())
156
157 >>> all_test_file_paths = sorted(unique_file_paths)
158
159
160=== modified file 'lib/lp/archivepublisher/tests/test_deathrow.py'
161--- lib/lp/archivepublisher/tests/test_deathrow.py 2012-01-01 02:58:52 +0000
162+++ lib/lp/archivepublisher/tests/test_deathrow.py 2016-10-02 12:40:36 +0000
163@@ -51,12 +51,12 @@
164 diskpool = DiskPool(pool_path, temp_path, logger)
165 return DeathRow(archive, diskpool, logger)
166
167- def getDiskPoolPath(self, pub_file, diskpool):
168+ def getDiskPoolPath(self, pub, pub_file, diskpool):
169 """Return the absolute path to a published file in the disk pool/."""
170 return diskpool.pathFor(
171- pub_file.componentname.encode('utf-8'),
172- pub_file.sourcepackagename.encode('utf8'),
173- pub_file.libraryfilealiasfilename.encode('utf-8'))
174+ pub.component.name.encode('utf-8'),
175+ pub.source_package_name.encode('utf8'),
176+ pub_file.libraryfile.filename.encode('utf-8'))
177
178 def assertIsFile(self, path):
179 """Assert the path exists and is a regular file."""
180@@ -112,10 +112,10 @@
181 for pub in test_publications:
182 pub.publish(deathrow.diskpool, deathrow.logger)
183 [main_dsc_path] = [
184- self.getDiskPoolPath(pub_file, deathrow.diskpool)
185+ self.getDiskPoolPath(source_main, pub_file, deathrow.diskpool)
186 for pub_file in source_main.files]
187 [universe_dsc_path] = [
188- self.getDiskPoolPath(pub_file, deathrow.diskpool)
189+ self.getDiskPoolPath(source_universe, pub_file, deathrow.diskpool)
190 for pub_file in source_universe.files]
191 self.assertIsFile(main_dsc_path)
192 self.assertIsLink(universe_dsc_path)
193
194=== modified file 'lib/lp/archivepublisher/tests/test_ftparchive.py'
195--- lib/lp/archivepublisher/tests/test_ftparchive.py 2016-05-04 14:47:28 +0000
196+++ lib/lp/archivepublisher/tests/test_ftparchive.py 2016-10-02 12:40:36 +0000
197@@ -373,8 +373,8 @@
198 binary_files = fa.getBinaryFiles(
199 hoary, PackagePublishingPocket.RELEASE)
200 expected_files = [
201+ ('foo', 'foo_666_hppa.deb', 'main', 'binary-hppa'),
202 ('pmount', 'pmount_1.9-1_all.deb', 'main', 'binary-hppa'),
203- ('foo', 'foo_666_hppa.deb', 'main', 'binary-hppa'),
204 ]
205 self.assertEqual(expected_files, list(binary_files))
206
207@@ -387,9 +387,9 @@
208 binary_files = fa.getBinaryFiles(
209 hoary, PackagePublishingPocket.RELEASE)
210 expected_files = [
211- ('pmount', 'pmount_1.9-1_all.deb', 'main', 'binary-hppa'),
212- ('foo', 'foo_666_hppa.deb', 'main', 'binary-hppa'),
213 ('foo', 'foo-dbgsym_666_hppa.ddeb', 'main', 'binary-hppa'),
214+ ('foo', 'foo_666_hppa.deb', 'main', 'binary-hppa'),
215+ ('pmount', 'pmount_1.9-1_all.deb', 'main', 'binary-hppa'),
216 ]
217 self.assertEqual(expected_files, list(binary_files))
218
219
220=== modified file 'lib/lp/soyuz/configure.zcml'
221--- lib/lp/soyuz/configure.zcml 2016-07-29 06:49:41 +0000
222+++ lib/lp/soyuz/configure.zcml 2016-10-02 12:40:36 +0000
223@@ -43,17 +43,6 @@
224 set_schema="lp.soyuz.interfaces.publishing.IBinaryPackagePublishingHistory"/>
225 </class>
226
227- <!-- BinaryPackageFilePublishing -->
228-
229- <class
230- class="lp.soyuz.model.publishing.BinaryPackageFilePublishing">
231- <allow
232- interface="lp.soyuz.interfaces.publishing.IBinaryPackageFilePublishing"/>
233-
234- <!-- XXX cprov 2006-06-14: missing security adapter -->
235-
236- </class>
237-
238 <!-- DistroSeriesPackageCache -->
239 <class
240 class="lp.soyuz.model.distroseriespackagecache.DistroSeriesPackageCache">
241@@ -98,17 +87,6 @@
242 set_schema="lp.soyuz.interfaces.publishing.ISourcePackagePublishingHistory"/>
243 </class>
244
245- <!-- SourcePackageFilePublishing -->
246-
247- <class
248- class="lp.soyuz.model.publishing.SourcePackageFilePublishing">
249- <allow
250- interface="lp.soyuz.interfaces.publishing.ISourcePackageFilePublishing"/>
251-
252- <!-- XXX cprov 2006-06-14: Missing security adapter. -->
253-
254- </class>
255-
256 <!-- PublishingSet -->
257
258 <class
259
260=== modified file 'lib/lp/soyuz/doc/publishing.txt'
261--- lib/lp/soyuz/doc/publishing.txt 2016-07-29 07:37:33 +0000
262+++ lib/lp/soyuz/doc/publishing.txt 2016-10-02 12:40:36 +0000
263@@ -111,7 +111,7 @@
264
265 >>> pub = spph.archive.getPublishedSources(name=u"iceweasel").first()
266 >>> print pub.changesFileUrl()
267- http://launchpad.dev/ubuntu/+archive/primary/+files/mozilla-firefox_0.9_i386.changes
268+ http://.../ubuntu/+archive/primary/+files/mozilla-firefox_0.9_i386.changes
269
270 There is also a helper property to determine whether the current release for
271 this package in the distroseries is newer than this publishing. Nothing is
272@@ -132,7 +132,6 @@
273 ... distroseries=pub.distroseries, version="1.1",
274 ... sourcename='iceweasel')
275
276- >>> from lp.services.propertycache import get_property_cache
277 >>> del get_property_cache(pub).newer_distroseries_version
278 >>> print pub.newer_distroseries_version.title
279 iceweasel 1.1 source package in Ubuntu
280@@ -176,8 +175,8 @@
281 ... IPublishingSet)
282 >>> ps = getUtility(IPublishingSet)
283 >>> unpublished_builds = ps.getUnpublishedBuildsForSources([spph])
284- >>> for _, build, _ in sorted(unpublished_builds, key=lambda b:b[1].title):
285- ... print build.title
286+ >>> for _, b, _ in sorted(unpublished_builds, key=lambda b:b[1].title):
287+ ... print b.title
288 hppa build of abc 666 in ubuntutest breezy-autotest RELEASE
289 i386 build of abc 666 in ubuntutest breezy-autotest RELEASE
290
291@@ -309,10 +308,10 @@
292
293 Retrieve any SourcePackagePublishingHistory entry.
294
295+ >>> from lp.soyuz.interfaces.files import (
296+ ... ISourcePackageReleaseFile)
297 >>> from lp.soyuz.interfaces.publishing import (
298- ... IBinaryPackagePublishingHistory,
299- ... ISourcePackageFilePublishing,
300- ... )
301+ ... IBinaryPackagePublishingHistory)
302 >>> spph = SourcePackagePublishingHistory.get(10)
303
304 >>> print spph.displayname
305@@ -321,14 +320,12 @@
306
307 Files published are accessible via the files property:
308
309- >>> any_pub_file = spph.files[-1]
310- >>> ISourcePackageFilePublishing.providedBy(any_pub_file)
311+ >>> any_pub_file = spph.files[0]
312+ >>> ISourcePackageReleaseFile.providedBy(any_pub_file)
313 True
314
315- >>> [(pub_file.libraryfilealias.filename, pub_file.archive_url)
316- ... for pub_file in spph.files]
317- [(u'alsa-utils_1.0.8-1ubuntu1.dsc',
318- u'http://archive.launchpad.dev/ubuntu/pool/main/a/alsa-utils/alsa-utils_1.0.8-1ubuntu1.dsc')]
319+ >>> spph.files[0].libraryfile.filename
320+ u'alsa-utils_1.0.8-1ubuntu1.dsc'
321
322
323 Deletion and obsolescence
324@@ -878,8 +875,8 @@
325 Symmetric behaviour is offered for BinaryPackagePublishing,
326 BinaryPackageFile and IBinaryPackagePublishingHistory
327
328- >>> from lp.soyuz.interfaces.publishing import (
329- ... IBinaryPackageFilePublishing)
330+ >>> from lp.soyuz.interfaces.files import (
331+ ... IBinaryPackageFile)
332
333 >>> bpph = BinaryPackagePublishingHistory.get(15)
334 >>> print bpph.displayname
335@@ -889,18 +886,12 @@
336 True
337
338 >>> any_file = bpph.files[-1]
339- >>> IBinaryPackageFilePublishing.providedBy(any_file)
340+ >>> IBinaryPackageFile.providedBy(any_file)
341 True
342
343- >>> [pub_file.libraryfilealias.filename for pub_file in bpph.files]
344+ >>> [pub_file.libraryfile.filename for pub_file in bpph.files]
345 [u'mozilla-firefox_0.9_i386.deb']
346
347- >>> debian = bpph.distroarchseries.distroseries.distribution
348- >>> discard = factory.makePublisherConfig(
349- ... distribution=debian, base_url=u"http://archive.launchpad.dev")
350- >>> [pub_file.archive_url for pub_file in bpph.files]
351- [u'http://archive.launchpad.dev/debian/pool/universe/m/mozilla-firefox/mozilla-firefox_0.9_i386.deb']
352-
353 Binary publishing records also have a download count, which contains
354 the number of downloads of this binary package release in this archive.
355
356
357=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
358--- lib/lp/soyuz/interfaces/publishing.py 2015-11-08 01:09:46 +0000
359+++ lib/lp/soyuz/interfaces/publishing.py 2016-10-02 12:40:36 +0000
360@@ -8,14 +8,11 @@
361 __all__ = [
362 'DeletionError',
363 'IArchiveSafePublisher',
364- 'IBinaryPackageFilePublishing',
365 'IBinaryPackagePublishingHistory',
366 'IBinaryPackagePublishingHistoryEdit',
367 'IBinaryPackagePublishingHistoryPublic',
368- 'IFilePublishing',
369 'IPublishingEdit',
370 'IPublishingSet',
371- 'ISourcePackageFilePublishing',
372 'ISourcePackagePublishingHistory',
373 'ISourcePackagePublishingHistoryEdit',
374 'ISourcePackagePublishingHistoryPublic',
375@@ -204,63 +201,11 @@
376 # deleted in tandem.
377
378
379-class IFilePublishing(Interface):
380- """Base interface for *FilePublishing classes"""
381-
382- distribution = Int(
383- title=_('Distribution ID'), required=True, readonly=True,
384- )
385- distroseriesname = TextLine(
386- title=_('Series name'), required=True, readonly=True,
387- )
388- componentname = TextLine(
389- title=_('Component name'), required=True, readonly=True,
390- )
391- publishingstatus = Int(
392- title=_('Package publishing status'), required=True, readonly=True,
393- )
394- pocket = Int(
395- title=_('Package publishing pocket'), required=True, readonly=True,
396- )
397- archive = Int(
398- title=_('Archive ID'), required=True, readonly=True,
399- )
400- libraryfilealias = Int(
401- title=_('Binarypackage file alias'), required=True, readonly=True,
402- )
403- libraryfilealiasfilename = TextLine(
404- title=_('File name'), required=True, readonly=True,
405- )
406- archive_url = Attribute('The on-archive URL for the published file.')
407-
408- publishing_record = Attribute(
409- "Return the Source or Binary publishing record "
410- "(in the form of I{Source,Binary}PackagePublishingHistory).")
411-
412- def publish(diskpool, log):
413- """Publish or ensure contents of this file in the archive.
414-
415- Create symbolic link to files already present in different component
416- or add file from librarian if it's not present. Update the database
417- to represent the current archive state.
418- """
419-
420 #
421 # Source package publishing
422 #
423
424
425-class ISourcePackageFilePublishing(IFilePublishing):
426- """Source package release files and their publishing status"""
427- sourcepackagename = TextLine(
428- title=_('Binary package name'), required=True, readonly=True,
429- )
430- sourcepackagepublishing = Int(
431- title=_('Sourcepackage publishing record id'), required=True,
432- readonly=True,
433- )
434-
435-
436 class ISourcePackagePublishingHistoryPublic(IPublishingView):
437 """A source package publishing history record."""
438 id = Int(
439@@ -639,20 +584,6 @@
440 #
441
442
443-class IBinaryPackageFilePublishing(IFilePublishing):
444- """Binary package files and their publishing status"""
445- # Note that it is really /source/ package name below, and not a
446- # thinko; at least, that's what Celso tells me the code uses
447- # -- kiko, 2006-03-22
448- sourcepackagename = TextLine(
449- title=_('Source package name'), required=True, readonly=True,
450- )
451- binarypackagepublishing = Int(
452- title=_('Binary Package publishing record id'), required=True,
453- readonly=True,
454- )
455-
456-
457 class IBinaryPackagePublishingHistoryPublic(IPublishingView):
458 """A binary package publishing record."""
459
460@@ -666,6 +597,8 @@
461 required=False, readonly=False)
462 binarypackagerelease = Attribute(
463 "The binary package release being published")
464+ source_package_name = Attribute(
465+ 'The source package name that built this binary.')
466 distroarchseriesID = Int(
467 title=_("The DB id for the distroarchseries."),
468 required=False, readonly=False)
469
470=== modified file 'lib/lp/soyuz/model/publishing.py'
471--- lib/lp/soyuz/model/publishing.py 2016-07-29 06:49:41 +0000
472+++ lib/lp/soyuz/model/publishing.py 2016-10-02 12:40:36 +0000
473@@ -4,12 +4,10 @@
474 __metaclass__ = type
475
476 __all__ = [
477- 'BinaryPackageFilePublishing',
478 'BinaryPackagePublishingHistory',
479 'get_current_source_releases',
480 'makePoolPath',
481 'PublishingSet',
482- 'SourcePackageFilePublishing',
483 'SourcePackagePublishingHistory',
484 ]
485
486@@ -91,10 +89,8 @@
487 from lp.soyuz.interfaces.publishing import (
488 active_publishing_status,
489 DeletionError,
490- IBinaryPackageFilePublishing,
491 IBinaryPackagePublishingHistory,
492 IPublishingSet,
493- ISourcePackageFilePublishing,
494 ISourcePackagePublishingHistory,
495 name_priority_map,
496 OverrideError,
497@@ -142,122 +138,6 @@
498 return [ProxiedLibraryFileAlias(file, parent).http_url for file in files]
499
500
501-class FilePublishingBase:
502- """Base class to publish files in the archive."""
503-
504- def publish(self, diskpool, log):
505- """See IFilePublishing."""
506- # XXX cprov 2006-06-12 bug=49510: The encode should not be needed
507- # when retrieving data from DB.
508- source = self.sourcepackagename.encode('utf-8')
509- component = self.componentname.encode('utf-8')
510- filename = self.libraryfilealiasfilename.encode('utf-8')
511- filealias = self.libraryfilealias
512- sha1 = filealias.content.sha1
513- path = diskpool.pathFor(component, source, filename)
514-
515- action = diskpool.addFile(component, source, filename, sha1, filealias)
516- if action == diskpool.results.FILE_ADDED:
517- log.debug("Added %s from library" % path)
518- elif action == diskpool.results.SYMLINK_ADDED:
519- log.debug("%s created as a symlink." % path)
520- elif action == diskpool.results.NONE:
521- log.debug("%s is already in pool with the same content." % path)
522-
523- @property
524- def archive_url(self):
525- """See IFilePublishing."""
526- return (self.archive.archive_url + "/" +
527- makePoolPath(self.sourcepackagename, self.componentname) +
528- "/" +
529- self.libraryfilealiasfilename)
530-
531-
532-@implementer(ISourcePackageFilePublishing)
533-class SourcePackageFilePublishing(FilePublishingBase, SQLBase):
534- """Source package release files and their publishing status.
535-
536- Represents the source portion of the pool.
537- """
538-
539- _idType = unicode
540- _defaultOrder = "id"
541-
542- distribution = ForeignKey(dbName='distribution',
543- foreignKey="Distribution",
544- unique=False,
545- notNull=True)
546-
547- sourcepackagepublishing = ForeignKey(
548- dbName='sourcepackagepublishing',
549- foreignKey='SourcePackagePublishingHistory')
550-
551- libraryfilealias = ForeignKey(
552- dbName='libraryfilealias', foreignKey='LibraryFileAlias',
553- notNull=True)
554-
555- libraryfilealiasfilename = StringCol(dbName='libraryfilealiasfilename',
556- unique=False, notNull=True)
557-
558- componentname = StringCol(dbName='componentname', unique=False,
559- notNull=True)
560-
561- sourcepackagename = StringCol(dbName='sourcepackagename', unique=False,
562- notNull=True)
563-
564- distroseriesname = StringCol(dbName='distroseriesname', unique=False,
565- notNull=True)
566-
567- publishingstatus = EnumCol(dbName='publishingstatus', unique=False,
568- notNull=True, schema=PackagePublishingStatus)
569-
570- pocket = EnumCol(dbName='pocket', unique=False,
571- notNull=True, schema=PackagePublishingPocket)
572-
573- archive = ForeignKey(dbName="archive", foreignKey="Archive", notNull=True)
574-
575- @property
576- def publishing_record(self):
577- """See `IFilePublishing`."""
578- return self.sourcepackagepublishing
579-
580-
581-@implementer(IBinaryPackageFilePublishing)
582-class BinaryPackageFilePublishing(FilePublishingBase, SQLBase):
583- """A binary package file which is published.
584-
585- Represents the binary portion of the pool.
586- """
587-
588- _idType = unicode
589- _defaultOrder = "id"
590-
591- binarypackagepublishing = ForeignKey(
592- dbName='binarypackagepublishing',
593- foreignKey='BinaryPackagePublishingHistory', immutable=True)
594-
595- libraryfilealias = ForeignKey(
596- dbName='libraryfilealias', foreignKey='LibraryFileAlias',
597- notNull=True)
598-
599- libraryfilealiasfilename = StringCol(dbName='libraryfilealiasfilename',
600- unique=False, notNull=True,
601- immutable=True)
602-
603- componentname = StringCol(dbName='componentname', unique=False,
604- notNull=True, immutable=True)
605-
606- sourcepackagename = StringCol(dbName='sourcepackagename', unique=False,
607- notNull=True, immutable=True)
608-
609- archive = ForeignKey(dbName="archive", foreignKey="Archive", notNull=True)
610-
611- @property
612- def publishing_record(self):
613- """See `ArchiveFilePublisherBase`."""
614- return self.binarypackagepublishing
615-
616-
617 class ArchivePublisherBase:
618 """Base class for `IArchivePublisher`."""
619
620@@ -277,7 +157,24 @@
621 """See `IPublishing`"""
622 try:
623 for pub_file in self.files:
624- pub_file.publish(diskpool, log)
625+ # XXX cprov 2006-06-12 bug=49510: The encode should not
626+ # be needed when retrieving data from DB.
627+ source = self.source_package_name.encode('utf-8')
628+ component = self.component.name.encode('utf-8')
629+ filename = pub_file.libraryfile.filename.encode('utf-8')
630+ filealias = pub_file.libraryfile
631+ sha1 = filealias.content.sha1
632+ path = diskpool.pathFor(component, source, filename)
633+
634+ action = diskpool.addFile(
635+ component, source, filename, sha1, filealias)
636+ if action == diskpool.results.FILE_ADDED:
637+ log.debug("Added %s from library" % path)
638+ elif action == diskpool.results.SYMLINK_ADDED:
639+ log.debug("%s created as a symlink." % path)
640+ elif action == diskpool.results.NONE:
641+ log.debug(
642+ "%s is already in pool with the same content." % path)
643 except PoolFileOverwriteError as e:
644 message = "PoolFileOverwriteError: %s, skipping." % e
645 properties = [('error-explanation', message)]
646@@ -500,10 +397,10 @@
647 @property
648 def files(self):
649 """See `IPublishing`."""
650- preJoins = ['libraryfilealias', 'libraryfilealias.content']
651-
652- return SourcePackageFilePublishing.selectBy(
653- sourcepackagepublishing=self).prejoin(preJoins)
654+ files = self.sourcepackagerelease.files
655+ lfas = bulk.load_related(LibraryFileAlias, files, ['libraryfileID'])
656+ bulk.load_related(LibraryFileContent, lfas, ['contentID'])
657+ return files
658
659 def getSourceAndBinaryLibraryFiles(self):
660 """See `IPublishing`."""
661@@ -751,10 +648,10 @@
662 @property
663 def files(self):
664 """See `IPublishing`."""
665- preJoins = ['libraryfilealias', 'libraryfilealias.content']
666-
667- return BinaryPackageFilePublishing.selectBy(
668- binarypackagepublishing=self).prejoin(preJoins)
669+ files = self.binarypackagerelease.files
670+ lfas = bulk.load_related(LibraryFileAlias, files, ['libraryfileID'])
671+ bulk.load_related(LibraryFileContent, lfas, ['contentID'])
672+ return files
673
674 @property
675 def distroseries(self):
676@@ -778,6 +675,11 @@
677 return self.binarypackagerelease.build
678
679 @property
680+ def source_package_name(self):
681+ """See `ISourcePackagePublishingHistory`"""
682+ return self.binarypackagerelease.sourcepackagename
683+
684+ @property
685 def architecture_specific(self):
686 """See `IBinaryPackagePublishingHistory`"""
687 return self.binarypackagerelease.architecturespecific
688
689=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
690--- lib/lp/soyuz/tests/test_publishing.py 2016-06-17 15:46:57 +0000
691+++ lib/lp/soyuz/tests/test_publishing.py 2016-10-02 12:40:36 +0000
692@@ -701,7 +701,7 @@
693 for pub in pubs:
694 pub.publish(self.disk_pool, self.logger)
695 self.assertEqual(PackagePublishingStatus.PUBLISHED, pub.status)
696- filename = pub.files[0].libraryfilealias.filename
697+ filename = pub.files[0].libraryfile.filename
698 path = "%s/main/d/dbg/%s" % (self.pool_dir, filename)
699 existence_map[filename] = os.path.exists(path)
700 return existence_map