def updateDistroSeriesCache(self, distroseries, archive):
        """Update package caches for the given location."""
        self.logger.info('%s %s %s starting' % (
            distroseries.distribution.name, distroseries.name,
            archive.displayname))

        DistroSeriesPackageCache.removeOld(
            distroseries, archive=archive, log=self.logger)

        updates = DistroSeriesPackageCache.updateAll(
            distroseries, archive=archive, ztm=self.txn, log=self.logger)

        if updates > 0:
            self.txn.commit()
Esempio n. 2
0
    def updateDistroSeriesCache(self, distroseries, archive):
        """Update package caches for the given location."""
        self.logger.info('%s %s %s starting' %
                         (distroseries.distribution.name, distroseries.name,
                          archive.displayname))

        DistroSeriesPackageCache.removeOld(distroseries,
                                           archive=archive,
                                           log=self.logger)

        updates = DistroSeriesPackageCache.updateAll(distroseries,
                                                     archive=archive,
                                                     ztm=self.txn,
                                                     log=self.logger)

        if updates > 0:
            self.txn.commit()
    def cache(self):
        """See IDistroArchSeriesBinaryPackage."""
        from lp.soyuz.model.distroseriespackagecache import (
            DistroSeriesPackageCache)
        query = """
            distroseries = %s AND
            archive IN %s AND
            binarypackagename = %s
        """ % sqlvalues(self.distroseries,
                        self.distribution.all_distro_archive_ids,
                        self.binarypackagename)

        return DistroSeriesPackageCache.selectOne(query)
    def cache(self):
        """See IDistroArchSeriesBinaryPackage."""
        from lp.soyuz.model.distroseriespackagecache import (
            DistroSeriesPackageCache)
        query = """
            distroseries = %s AND
            archive IN %s AND
            binarypackagename = %s
        """ % sqlvalues(self.distroseries,
                        self.distribution.all_distro_archive_ids,
                        self.binarypackagename)

        return DistroSeriesPackageCache.selectOne(query)
    def test_cache_attribute_when_two_cache_objects(self):
        # We have situations where there are cache objects for each
        # distro archive - we need to handle this situation without
        # OOPSing - see bug 580181.
        distro_archive_1 = self.distribution.main_archive
        distro_archive_2 = self.distribution.all_distro_archives[1]

        # Publish the same binary in another distro archive.
        self.publisher.getPubBinaries(binaryname='foo-bin',
                                      summary='Foo is the best',
                                      archive=distro_archive_2)

        logger = BufferLogger()
        with dbuser(config.statistician.dbuser):
            DistroSeriesPackageCache._update(self.distroseries,
                                             self.binary_package_name,
                                             distro_archive_1, logger)

            DistroSeriesPackageCache._update(self.distroseries,
                                             self.binary_package_name,
                                             distro_archive_2, logger)

        self.failUnlessEqual('Foo is the best',
                             self.distroseries_binary_package.summary)
    def test_cache_attribute_when_two_cache_objects(self):
        # We have situations where there are cache objects for each
        # distro archive - we need to handle this situation without
        # OOPSing - see bug 580181.
        distro_archive_1 = self.distribution.main_archive
        distro_archive_2 = self.distribution.all_distro_archives[1]

        # Publish the same binary in another distro archive.
        self.publisher.getPubBinaries(
            binaryname='foo-bin', summary='Foo is the best',
            archive=distro_archive_2)

        logger = BufferLogger()
        with dbuser(config.statistician.dbuser):
            DistroSeriesPackageCache._update(
                self.distroseries, self.binary_package_name, distro_archive_1,
                logger)

            DistroSeriesPackageCache._update(
                self.distroseries, self.binary_package_name, distro_archive_2,
                logger)

        self.failUnlessEqual(
            'Foo is the best', self.distroseries_binary_package.summary)