[packagekit] The yum percentage changed callback for refresh-cache

Richard Hughes hughsient at gmail.com
Sun Oct 21 16:07:09 PDT 2007


At the moment we have the yum refresh cache percentage callback as big
jumps, e.g. 0, 25%, 50%, 75% and 100% - this isn't very nice when the
time between jumps can be a few minutes.

We seem to get lots of subpercentage updates, which are good, so could
we _refine_ the percentage updates with this information?

i.e. we still do the "bump" computation, but add to it the
subpercentage / len(self.yumbase.repos.listEnabled()) to get a much
smoother scale.

Does this make sense?

The code that works out the jumps is this:

        self.percentage(0)

        pct = 0
        try:
            if len(self.yumbase.repos.listEnabled()) == 0:
                self.percentage(100)
                return

            #work out the slice for each one
            bump = (100/len(self.yumbase.repos.listEnabled()))/2

            for repo in self.yumbase.repos.listEnabled():
                repo.metadata_expire = 0
                self.yumbase.repos.populateSack(which=[repo.id], mdtype='metadata', cacheonly=1)
                pct+=bump
                self.percentage(pct)
                self.yumbase.repos.populateSack(which=[repo.id], mdtype='filelists', cacheonly=1)
                pct+=bump
                self.percentage(pct)

Yum legends, take your marks, get set, go!

Thanks,

Richard.





More information about the PackageKit mailing list