← Back to team overview

launchpad-reviewers team mailing list archive

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

 

William Grant has proposed merging lp:~wgrant/launchpad/de-view-publisher into lp:launchpad.

Commit message:
Abolish {Source,Binary}PackageFilePublishing.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/de-view-publisher/+merge/306688

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).
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/de-view-publisher into lp:launchpad.
=== modified file 'lib/lp/archivepublisher/deathrow.py'
--- lib/lp/archivepublisher/deathrow.py	2012-08-17 11:15:35 +0000
+++ lib/lp/archivepublisher/deathrow.py	2016-09-24 06:48:43 +0000
@@ -223,16 +223,16 @@
             See `canRemove` for more information.
             """
             for pub_file in pub_record.files:
-                filename = pub_file.libraryfilealiasfilename
-                file_md5 = pub_file.libraryfilealias.content.md5
+                filename = pub_file.libraryfile.filename
+                file_md5 = pub_file.libraryfile.content.md5
 
                 self.logger.debug("Checking %s (%s)" % (filename, file_md5))
 
                 # Calculating the file path in pool.
                 pub_file_details = (
-                    pub_file.libraryfilealiasfilename,
-                    pub_file.sourcepackagename,
-                    pub_file.componentname,
+                    pub_file.libraryfile.filename,
+                    pub_record.source_package_name,
+                    pub_record.component_name,
                     )
                 file_path = self.diskpool.pathFor(*pub_file_details)
 
@@ -243,7 +243,7 @@
                 if (filename, file_md5) in considered_files:
                     self.logger.debug("Already verified.")
                     if file_path in condemned_files:
-                        condemned_records.add(pub_file.publishing_record)
+                        condemned_records.add(pub_record)
                     continue
                 considered_files.add((filename, file_md5))
 
@@ -255,7 +255,7 @@
                 # Update local containers, in preparation to file removal.
                 details.setdefault(file_path, pub_file_details)
                 condemned_files.add(file_path)
-                condemned_records.add(pub_file.publishing_record)
+                condemned_records.add(pub_record)
 
         # Check source and binary publishing records.
         for pub_record in condemned_source_files:

=== modified file 'lib/lp/archivepublisher/model/ftparchive.py'
--- lib/lp/archivepublisher/model/ftparchive.py	2016-04-05 02:07:48 +0000
+++ lib/lp/archivepublisher/model/ftparchive.py	2016-09-24 06:48:43 +0000
@@ -36,10 +36,12 @@
 from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
 from lp.soyuz.model.component import Component
 from lp.soyuz.model.distroarchseries import DistroArchSeries
-from lp.soyuz.model.files import BinaryPackageFile
+from lp.soyuz.model.files import (
+    BinaryPackageFile,
+    SourcePackageReleaseFile,
+    )
 from lp.soyuz.model.publishing import (
     BinaryPackagePublishingHistory,
-    SourcePackageFilePublishing,
     SourcePackagePublishingHistory,
     )
 from lp.soyuz.model.section import Section
@@ -562,19 +564,31 @@
 
         :return: a `ResultSet` with the source files information tuples.
         """
-        store = IStore(SourcePackagePublishingHistory)
-        result_set = store.using(SourcePackageFilePublishing).find(
-            (SourcePackageFilePublishing.sourcepackagename,
-             SourcePackageFilePublishing.libraryfilealiasfilename,
-             SourcePackageFilePublishing.componentname),
-            SourcePackageFilePublishing.distribution == self.distro,
-            SourcePackageFilePublishing.archive == self.publisher.archive,
-            SourcePackageFilePublishing.distroseriesname == distroseries.name,
-            SourcePackageFilePublishing.pocket == pocket,
-            SourcePackageFilePublishing.publishingstatus ==
-                PackagePublishingStatus.PUBLISHED)
+        columns = (
+            SourcePackageName.name,
+            LibraryFileAlias.filename,
+            Component.name,
+            )
+        join_conditions = [
+            SourcePackageReleaseFile.sourcepackagereleaseID ==
+                SourcePackagePublishingHistory.sourcepackagereleaseID,
+            SourcePackageName.id ==
+                SourcePackagePublishingHistory.sourcepackagenameID,
+            LibraryFileAlias.id == SourcePackageReleaseFile.libraryfileID,
+            Component.id == SourcePackagePublishingHistory.componentID,
+            ]
+        select_conditions = [
+            SourcePackagePublishingHistory.archive == self.publisher.archive,
+            SourcePackagePublishingHistory.distroseriesID == distroseries.id,
+            SourcePackagePublishingHistory.pocket == pocket,
+            SourcePackagePublishingHistory.status ==
+                PackagePublishingStatus.PUBLISHED,
+            ]
 
-        return result_set.order_by(Desc(SourcePackageFilePublishing.id))
+        result_set = IStore(SourcePackageRelease).find(
+            columns, *(join_conditions + select_conditions))
+        return result_set.order_by(
+            LibraryFileAlias.filename, SourcePackageReleaseFile.id)
 
     def getBinaryFiles(self, distroseries, pocket):
         """Fetch publishing information about all published binary files.
@@ -599,16 +613,13 @@
             BinaryPackageFile.binarypackagereleaseID ==
                 BinaryPackagePublishingHistory.binarypackagereleaseID,
             BinaryPackageBuild.id == BinaryPackageRelease.buildID,
-            SourcePackageRelease.id ==
-                BinaryPackageBuild.source_package_release_id,
-            SourcePackageName.id == SourcePackageRelease.sourcepackagenameID,
+            SourcePackageName.id == BinaryPackageBuild.source_package_name_id,
             LibraryFileAlias.id == BinaryPackageFile.libraryfileID,
             DistroArchSeries.id ==
                 BinaryPackagePublishingHistory.distroarchseriesID,
             Component.id == BinaryPackagePublishingHistory.componentID,
             ]
         select_conditions = [
-            BinaryPackagePublishingHistory.dateremoved == None,
             DistroArchSeries.distroseriesID == distroseries.id,
             BinaryPackagePublishingHistory.archive == self.publisher.archive,
             BinaryPackagePublishingHistory.pocket == pocket,
@@ -621,10 +632,10 @@
                 BinaryPackageRelease.binpackageformat
                     != BinaryPackageFormat.DDEB)
 
-        result_set = IStore(SourcePackageRelease).find(
+        result_set = IStore(BinaryPackageRelease).find(
             columns, *(join_conditions + select_conditions))
         return result_set.order_by(
-            BinaryPackagePublishingHistory.id, BinaryPackageFile.id)
+            LibraryFileAlias.filename, BinaryPackageFile.id)
 
     def generateFileLists(self, fullpublish=False):
         """Collect currently published FilePublishings and write filelists."""

=== modified file 'lib/lp/archivepublisher/tests/deathrow.txt'
--- lib/lp/archivepublisher/tests/deathrow.txt	2011-04-05 08:28:30 +0000
+++ lib/lp/archivepublisher/tests/deathrow.txt	2016-09-24 06:48:43 +0000
@@ -202,12 +202,12 @@
     ...     for pub_file in pub.files:
     ...         for pub_file in pub.files:
     ...             file_path = quiet_disk_pool.pathFor(
-    ...                 pub_file.componentname.encode('utf-8'),
-    ...                 pub_file.sourcepackagename.encode('utf8'),
-    ...                 pub_file.libraryfilealiasfilename.encode('utf-8')
+    ...                 pub.component.name.encode('utf-8'),
+    ...                 pub.source_package_name.encode('utf8'),
+    ...                 pub_file.libraryfile.filename.encode('utf-8')
     ...              )
     ...             unique_file_paths.add(file_path)
-    ...             pub_file.publish(quiet_disk_pool, BufferLogger())
+    ...         pub.publish(quiet_disk_pool, BufferLogger())
 
     >>> all_test_file_paths = sorted(unique_file_paths)
 

=== modified file 'lib/lp/archivepublisher/tests/test_deathrow.py'
--- lib/lp/archivepublisher/tests/test_deathrow.py	2012-01-01 02:58:52 +0000
+++ lib/lp/archivepublisher/tests/test_deathrow.py	2016-09-24 06:48:43 +0000
@@ -51,12 +51,12 @@
         diskpool = DiskPool(pool_path, temp_path, logger)
         return DeathRow(archive, diskpool, logger)
 
-    def getDiskPoolPath(self, pub_file, diskpool):
+    def getDiskPoolPath(self, pub, pub_file, diskpool):
         """Return the absolute path to a published file in the disk pool/."""
         return diskpool.pathFor(
-            pub_file.componentname.encode('utf-8'),
-            pub_file.sourcepackagename.encode('utf8'),
-            pub_file.libraryfilealiasfilename.encode('utf-8'))
+            pub.component.name.encode('utf-8'),
+            pub.source_package_name.encode('utf8'),
+            pub_file.libraryfile.filename.encode('utf-8'))
 
     def assertIsFile(self, path):
         """Assert the path exists and is a regular file."""
@@ -112,10 +112,10 @@
         for pub in test_publications:
             pub.publish(deathrow.diskpool, deathrow.logger)
         [main_dsc_path] = [
-            self.getDiskPoolPath(pub_file, deathrow.diskpool)
+            self.getDiskPoolPath(source_main, pub_file, deathrow.diskpool)
             for pub_file in source_main.files]
         [universe_dsc_path] = [
-            self.getDiskPoolPath(pub_file, deathrow.diskpool)
+            self.getDiskPoolPath(source_universe, pub_file, deathrow.diskpool)
             for pub_file in source_universe.files]
         self.assertIsFile(main_dsc_path)
         self.assertIsLink(universe_dsc_path)

=== modified file 'lib/lp/archivepublisher/tests/test_ftparchive.py'
--- lib/lp/archivepublisher/tests/test_ftparchive.py	2016-05-04 14:47:28 +0000
+++ lib/lp/archivepublisher/tests/test_ftparchive.py	2016-09-24 06:48:43 +0000
@@ -373,8 +373,8 @@
         binary_files = fa.getBinaryFiles(
             hoary, PackagePublishingPocket.RELEASE)
         expected_files = [
+            ('foo', 'foo_666_hppa.deb', 'main', 'binary-hppa'),
             ('pmount', 'pmount_1.9-1_all.deb', 'main', 'binary-hppa'),
-            ('foo', 'foo_666_hppa.deb', 'main', 'binary-hppa'),
             ]
         self.assertEqual(expected_files, list(binary_files))
 
@@ -387,9 +387,9 @@
         binary_files = fa.getBinaryFiles(
             hoary, PackagePublishingPocket.RELEASE)
         expected_files = [
-            ('pmount', 'pmount_1.9-1_all.deb', 'main', 'binary-hppa'),
-            ('foo', 'foo_666_hppa.deb', 'main', 'binary-hppa'),
             ('foo', 'foo-dbgsym_666_hppa.ddeb', 'main', 'binary-hppa'),
+            ('foo', 'foo_666_hppa.deb', 'main', 'binary-hppa'),
+            ('pmount', 'pmount_1.9-1_all.deb', 'main', 'binary-hppa'),
             ]
         self.assertEqual(expected_files, list(binary_files))
 

=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml	2016-07-29 06:49:41 +0000
+++ lib/lp/soyuz/configure.zcml	2016-09-24 06:48:43 +0000
@@ -43,17 +43,6 @@
                 set_schema="lp.soyuz.interfaces.publishing.IBinaryPackagePublishingHistory"/>
         </class>
 
-        <!-- BinaryPackageFilePublishing -->
-
-        <class
-            class="lp.soyuz.model.publishing.BinaryPackageFilePublishing">
-            <allow
-                interface="lp.soyuz.interfaces.publishing.IBinaryPackageFilePublishing"/>
-
-            <!-- XXX cprov 2006-06-14: missing security adapter -->
-
-        </class>
-
     <!-- DistroSeriesPackageCache -->
     <class
         class="lp.soyuz.model.distroseriespackagecache.DistroSeriesPackageCache">
@@ -98,17 +87,6 @@
                 set_schema="lp.soyuz.interfaces.publishing.ISourcePackagePublishingHistory"/>
         </class>
 
-        <!-- SourcePackageFilePublishing -->
-
-        <class
-            class="lp.soyuz.model.publishing.SourcePackageFilePublishing">
-            <allow
-                interface="lp.soyuz.interfaces.publishing.ISourcePackageFilePublishing"/>
-
-            <!-- XXX cprov 2006-06-14: Missing security adapter. -->
-
-        </class>
-
         <!-- PublishingSet -->
 
         <class

=== modified file 'lib/lp/soyuz/doc/publishing.txt'
--- lib/lp/soyuz/doc/publishing.txt	2016-07-29 07:37:33 +0000
+++ lib/lp/soyuz/doc/publishing.txt	2016-09-24 06:48:43 +0000
@@ -309,10 +309,10 @@
 
 Retrieve any SourcePackagePublishingHistory entry.
 
+    >>> from lp.soyuz.interfaces.files import (
+    ...     ISourcePackageReleaseFile)
     >>> from lp.soyuz.interfaces.publishing import (
-    ...     IBinaryPackagePublishingHistory,
-    ...     ISourcePackageFilePublishing,
-    ...     )
+    ...     IBinaryPackagePublishingHistory)
     >>> spph = SourcePackagePublishingHistory.get(10)
 
     >>> print spph.displayname
@@ -321,14 +321,12 @@
 
 Files published are accessible via the files property:
 
-    >>> any_pub_file = spph.files[-1]
-    >>> ISourcePackageFilePublishing.providedBy(any_pub_file)
+    >>> any_pub_file = spph.files[0]
+    >>> ISourcePackageReleaseFile.providedBy(any_pub_file)
     True
 
-    >>> [(pub_file.libraryfilealias.filename, pub_file.archive_url)
-    ...  for pub_file in spph.files]
-    [(u'alsa-utils_1.0.8-1ubuntu1.dsc',
-      u'http://archive.launchpad.dev/ubuntu/pool/main/a/alsa-utils/alsa-utils_1.0.8-1ubuntu1.dsc')]
+    >>> spph.files[0].libraryfile.filename
+    u'alsa-utils_1.0.8-1ubuntu1.dsc'
 
 
 Deletion and obsolescence
@@ -878,8 +876,8 @@
 Symmetric behaviour is offered for BinaryPackagePublishing,
 BinaryPackageFile and IBinaryPackagePublishingHistory
 
-    >>> from lp.soyuz.interfaces.publishing import (
-    ...     IBinaryPackageFilePublishing)
+    >>> from lp.soyuz.interfaces.files import (
+    ...     IBinaryPackageFile)
 
     >>> bpph = BinaryPackagePublishingHistory.get(15)
     >>> print bpph.displayname
@@ -889,18 +887,12 @@
     True
 
     >>> any_file = bpph.files[-1]
-    >>> IBinaryPackageFilePublishing.providedBy(any_file)
+    >>> IBinaryPackageFile.providedBy(any_file)
     True
 
-    >>> [pub_file.libraryfilealias.filename for pub_file in bpph.files]
+    >>> [pub_file.libraryfile.filename for pub_file in bpph.files]
     [u'mozilla-firefox_0.9_i386.deb']
 
-    >>> debian = bpph.distroarchseries.distroseries.distribution
-    >>> discard = factory.makePublisherConfig(
-    ...     distribution=debian, base_url=u"http://archive.launchpad.dev";)
-    >>> [pub_file.archive_url for pub_file in bpph.files]
-    [u'http://archive.launchpad.dev/debian/pool/universe/m/mozilla-firefox/mozilla-firefox_0.9_i386.deb']
-
 Binary publishing records also have a download count, which contains
 the number of downloads of this binary package release in this archive.
 

=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
--- lib/lp/soyuz/interfaces/publishing.py	2015-11-08 01:09:46 +0000
+++ lib/lp/soyuz/interfaces/publishing.py	2016-09-24 06:48:43 +0000
@@ -8,14 +8,11 @@
 __all__ = [
     'DeletionError',
     'IArchiveSafePublisher',
-    'IBinaryPackageFilePublishing',
     'IBinaryPackagePublishingHistory',
     'IBinaryPackagePublishingHistoryEdit',
     'IBinaryPackagePublishingHistoryPublic',
-    'IFilePublishing',
     'IPublishingEdit',
     'IPublishingSet',
-    'ISourcePackageFilePublishing',
     'ISourcePackagePublishingHistory',
     'ISourcePackagePublishingHistoryEdit',
     'ISourcePackagePublishingHistoryPublic',
@@ -204,63 +201,11 @@
         # deleted in tandem.
 
 
-class IFilePublishing(Interface):
-    """Base interface for *FilePublishing classes"""
-
-    distribution = Int(
-            title=_('Distribution ID'), required=True, readonly=True,
-            )
-    distroseriesname = TextLine(
-            title=_('Series name'), required=True, readonly=True,
-            )
-    componentname = TextLine(
-            title=_('Component name'), required=True, readonly=True,
-            )
-    publishingstatus = Int(
-            title=_('Package publishing status'), required=True, readonly=True,
-            )
-    pocket = Int(
-            title=_('Package publishing pocket'), required=True, readonly=True,
-            )
-    archive = Int(
-            title=_('Archive ID'), required=True, readonly=True,
-            )
-    libraryfilealias = Int(
-            title=_('Binarypackage file alias'), required=True, readonly=True,
-            )
-    libraryfilealiasfilename = TextLine(
-            title=_('File name'), required=True, readonly=True,
-            )
-    archive_url = Attribute('The on-archive URL for the published file.')
-
-    publishing_record = Attribute(
-        "Return the Source or Binary publishing record "
-        "(in the form of I{Source,Binary}PackagePublishingHistory).")
-
-    def publish(diskpool, log):
-        """Publish or ensure contents of this file in the archive.
-
-        Create symbolic link to files already present in different component
-        or add file from librarian if it's not present. Update the database
-        to represent the current archive state.
-        """
-
 #
 # Source package publishing
 #
 
 
-class ISourcePackageFilePublishing(IFilePublishing):
-    """Source package release files and their publishing status"""
-    sourcepackagename = TextLine(
-            title=_('Binary package name'), required=True, readonly=True,
-            )
-    sourcepackagepublishing = Int(
-            title=_('Sourcepackage publishing record id'), required=True,
-            readonly=True,
-            )
-
-
 class ISourcePackagePublishingHistoryPublic(IPublishingView):
     """A source package publishing history record."""
     id = Int(
@@ -639,20 +584,6 @@
 #
 
 
-class IBinaryPackageFilePublishing(IFilePublishing):
-    """Binary package files and their publishing status"""
-    # Note that it is really /source/ package name below, and not a
-    # thinko; at least, that's what Celso tells me the code uses
-    #   -- kiko, 2006-03-22
-    sourcepackagename = TextLine(
-            title=_('Source package name'), required=True, readonly=True,
-            )
-    binarypackagepublishing = Int(
-            title=_('Binary Package publishing record id'), required=True,
-            readonly=True,
-            )
-
-
 class IBinaryPackagePublishingHistoryPublic(IPublishingView):
     """A binary package publishing record."""
 
@@ -666,6 +597,8 @@
         required=False, readonly=False)
     binarypackagerelease = Attribute(
         "The binary package release being published")
+    source_package_name = Attribute(
+        'The source package name that built this binary.')
     distroarchseriesID = Int(
         title=_("The DB id for the distroarchseries."),
         required=False, readonly=False)

=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py	2016-07-29 06:49:41 +0000
+++ lib/lp/soyuz/model/publishing.py	2016-09-24 06:48:43 +0000
@@ -4,12 +4,10 @@
 __metaclass__ = type
 
 __all__ = [
-    'BinaryPackageFilePublishing',
     'BinaryPackagePublishingHistory',
     'get_current_source_releases',
     'makePoolPath',
     'PublishingSet',
-    'SourcePackageFilePublishing',
     'SourcePackagePublishingHistory',
     ]
 
@@ -91,10 +89,8 @@
 from lp.soyuz.interfaces.publishing import (
     active_publishing_status,
     DeletionError,
-    IBinaryPackageFilePublishing,
     IBinaryPackagePublishingHistory,
     IPublishingSet,
-    ISourcePackageFilePublishing,
     ISourcePackagePublishingHistory,
     name_priority_map,
     OverrideError,
@@ -142,122 +138,6 @@
     return [ProxiedLibraryFileAlias(file, parent).http_url for file in files]
 
 
-class FilePublishingBase:
-    """Base class to publish files in the archive."""
-
-    def publish(self, diskpool, log):
-        """See IFilePublishing."""
-        # XXX cprov 2006-06-12 bug=49510: The encode should not be needed
-        # when retrieving data from DB.
-        source = self.sourcepackagename.encode('utf-8')
-        component = self.componentname.encode('utf-8')
-        filename = self.libraryfilealiasfilename.encode('utf-8')
-        filealias = self.libraryfilealias
-        sha1 = filealias.content.sha1
-        path = diskpool.pathFor(component, source, filename)
-
-        action = diskpool.addFile(component, source, filename, sha1, filealias)
-        if action == diskpool.results.FILE_ADDED:
-            log.debug("Added %s from library" % path)
-        elif action == diskpool.results.SYMLINK_ADDED:
-            log.debug("%s created as a symlink." % path)
-        elif action == diskpool.results.NONE:
-            log.debug("%s is already in pool with the same content." % path)
-
-    @property
-    def archive_url(self):
-        """See IFilePublishing."""
-        return (self.archive.archive_url + "/" +
-                makePoolPath(self.sourcepackagename, self.componentname) +
-                "/" +
-                self.libraryfilealiasfilename)
-
-
-@implementer(ISourcePackageFilePublishing)
-class SourcePackageFilePublishing(FilePublishingBase, SQLBase):
-    """Source package release files and their publishing status.
-
-    Represents the source portion of the pool.
-    """
-
-    _idType = unicode
-    _defaultOrder = "id"
-
-    distribution = ForeignKey(dbName='distribution',
-                              foreignKey="Distribution",
-                              unique=False,
-                              notNull=True)
-
-    sourcepackagepublishing = ForeignKey(
-        dbName='sourcepackagepublishing',
-        foreignKey='SourcePackagePublishingHistory')
-
-    libraryfilealias = ForeignKey(
-        dbName='libraryfilealias', foreignKey='LibraryFileAlias',
-        notNull=True)
-
-    libraryfilealiasfilename = StringCol(dbName='libraryfilealiasfilename',
-                                         unique=False, notNull=True)
-
-    componentname = StringCol(dbName='componentname', unique=False,
-                              notNull=True)
-
-    sourcepackagename = StringCol(dbName='sourcepackagename', unique=False,
-                                  notNull=True)
-
-    distroseriesname = StringCol(dbName='distroseriesname', unique=False,
-                                  notNull=True)
-
-    publishingstatus = EnumCol(dbName='publishingstatus', unique=False,
-                               notNull=True, schema=PackagePublishingStatus)
-
-    pocket = EnumCol(dbName='pocket', unique=False,
-                     notNull=True, schema=PackagePublishingPocket)
-
-    archive = ForeignKey(dbName="archive", foreignKey="Archive", notNull=True)
-
-    @property
-    def publishing_record(self):
-        """See `IFilePublishing`."""
-        return self.sourcepackagepublishing
-
-
-@implementer(IBinaryPackageFilePublishing)
-class BinaryPackageFilePublishing(FilePublishingBase, SQLBase):
-    """A binary package file which is published.
-
-    Represents the binary portion of the pool.
-    """
-
-    _idType = unicode
-    _defaultOrder = "id"
-
-    binarypackagepublishing = ForeignKey(
-        dbName='binarypackagepublishing',
-        foreignKey='BinaryPackagePublishingHistory', immutable=True)
-
-    libraryfilealias = ForeignKey(
-        dbName='libraryfilealias', foreignKey='LibraryFileAlias',
-        notNull=True)
-
-    libraryfilealiasfilename = StringCol(dbName='libraryfilealiasfilename',
-                                         unique=False, notNull=True,
-                                         immutable=True)
-
-    componentname = StringCol(dbName='componentname', unique=False,
-                              notNull=True, immutable=True)
-
-    sourcepackagename = StringCol(dbName='sourcepackagename', unique=False,
-                                  notNull=True, immutable=True)
-
-    archive = ForeignKey(dbName="archive", foreignKey="Archive", notNull=True)
-
-    @property
-    def publishing_record(self):
-        """See `ArchiveFilePublisherBase`."""
-        return self.binarypackagepublishing
-
-
 class ArchivePublisherBase:
     """Base class for `IArchivePublisher`."""
 
@@ -277,7 +157,22 @@
         """See `IPublishing`"""
         try:
             for pub_file in self.files:
-                pub_file.publish(diskpool, log)
+                # XXX cprov 2006-06-12 bug=49510: The encode should not be needed
+                # when retrieving data from DB.
+                source = self.source_package_name.encode('utf-8')
+                component = self.component.name.encode('utf-8')
+                filename = pub_file.libraryfile.filename.encode('utf-8')
+                filealias = pub_file.libraryfile
+                sha1 = filealias.content.sha1
+                path = diskpool.pathFor(component, source, filename)
+
+                action = diskpool.addFile(component, source, filename, sha1, filealias)
+                if action == diskpool.results.FILE_ADDED:
+                    log.debug("Added %s from library" % path)
+                elif action == diskpool.results.SYMLINK_ADDED:
+                    log.debug("%s created as a symlink." % path)
+                elif action == diskpool.results.NONE:
+                    log.debug("%s is already in pool with the same content." % path)
         except PoolFileOverwriteError as e:
             message = "PoolFileOverwriteError: %s, skipping." % e
             properties = [('error-explanation', message)]
@@ -500,10 +395,10 @@
     @property
     def files(self):
         """See `IPublishing`."""
-        preJoins = ['libraryfilealias', 'libraryfilealias.content']
-
-        return SourcePackageFilePublishing.selectBy(
-            sourcepackagepublishing=self).prejoin(preJoins)
+        files = self.sourcepackagerelease.files
+        lfas = bulk.load_related(LibraryFileAlias, files, ['libraryfileID'])
+        bulk.load_related(LibraryFileContent, lfas, ['contentID'])
+        return files
 
     def getSourceAndBinaryLibraryFiles(self):
         """See `IPublishing`."""
@@ -751,10 +646,10 @@
     @property
     def files(self):
         """See `IPublishing`."""
-        preJoins = ['libraryfilealias', 'libraryfilealias.content']
-
-        return BinaryPackageFilePublishing.selectBy(
-            binarypackagepublishing=self).prejoin(preJoins)
+        files = self.binarypackagerelease.files
+        lfas = bulk.load_related(LibraryFileAlias, files, ['libraryfileID'])
+        bulk.load_related(LibraryFileContent, lfas, ['contentID'])
+        return files
 
     @property
     def distroseries(self):
@@ -778,6 +673,11 @@
         return self.binarypackagerelease.build
 
     @property
+    def source_package_name(self):
+        """See `ISourcePackagePublishingHistory`"""
+        return self.binarypackagerelease.sourcepackagename
+
+    @property
     def architecture_specific(self):
         """See `IBinaryPackagePublishingHistory`"""
         return self.binarypackagerelease.architecturespecific

=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py	2016-06-17 15:46:57 +0000
+++ lib/lp/soyuz/tests/test_publishing.py	2016-09-24 06:48:43 +0000
@@ -701,7 +701,7 @@
             for pub in pubs:
                 pub.publish(self.disk_pool, self.logger)
                 self.assertEqual(PackagePublishingStatus.PUBLISHED, pub.status)
-                filename = pub.files[0].libraryfilealias.filename
+                filename = pub.files[0].libraryfile.filename
                 path = "%s/main/d/dbg/%s" % (self.pool_dir, filename)
                 existence_map[filename] = os.path.exists(path)
             return existence_map


Follow ups