Bug 1048988 - [plugins] [api] add a hook for MD refresh
Summary: [plugins] [api] add a hook for MD refresh
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 20
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Ales Kozumplik
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2014-01-06 17:21 UTC by Elad Alfassa
Modified: 2014-09-30 23:42 UTC (History)
5 users (show)

Clone Of:
Last Closed: 2014-01-11 08:48:04 UTC

Attachments (Terms of Use)

Description Elad Alfassa 2014-01-06 17:21:00 UTC
For the bash completion plugin, I'd need a hook that will be called every time makecache completes.

Also, if someone runs dnf makecache --cacheonly, dnf should not download anything but run the hook anyway. This will allow the completion plugin to generate the cache it needs if the completion cache does not exist but dnf does have downloaded repository information stored.

Comment 1 Ales Kozumplik 2014-01-06 17:27:40 UTC
Elad, I thought the hook would be for any time the MD refresh happens, no? Some people never run makecache FWIW. I might have confused you about disliking the time penalty: I don't mind adding a few ms to every run where new metadata is downloaded, I just don't like adding a few ms to *every run*.

Comment 2 Elad Alfassa 2014-01-06 17:39:18 UTC
> I just don't like adding a few ms to *every run*.

neither do I.

> I thought the hook would be for any time the MD refresh happens, no?

You said that's hard. I suggested makecache as a compromise. The timer also runs makecache, so if we assume most people will not turn it off those few ms will be added to a background process, which means users won't notice the slowness, and it'd be also easier for you to implement.

Anyway, I'm okay with having that hook on MD refresh OR every time makecache is run. Either is fine for my use.

Comment 3 Ales Kozumplik 2014-01-07 15:20:59 UTC

I just looked at your plugin in detail, you do:

  available_packages = self.base.sack.query().available()

Which means you'll still have to wait for the sack() trigger to fire because you need the sack to be ready. So I guess what we really need is a way to determine if any MD has been updated during while the sack was built, rather then the hook. Admittedly a combination of the two can yield the same results but I think being able to tell where we got the MD from (cache vs. origin) is useful for more API clients then the refresh hook.

Comment 4 Elad Alfassa 2014-01-07 16:18:17 UTC
Makes sense, but need to make sure this value will be set to "origin" even if just one repo was updated.

Comment 5 Ales Kozumplik 2014-01-07 17:07:51 UTC
this value is now set per-repo (repo.metadata.fresh), see 7e793fc.

Comment 6 Elad Alfassa 2014-01-07 18:53:22 UTC
So I should loop on every enabled repo, and if repo.metadata.fresh is set, regen the cache?

Comment 7 Ales Kozumplik 2014-01-08 07:49:25 UTC

Comment 8 Fedora Update System 2014-01-09 14:40:28 UTC
dnf-0.4.11-1.fc20 has been submitted as an update for Fedora 20.

Comment 9 Fedora Update System 2014-01-10 08:00:11 UTC
Package dnf-0.4.11-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-0.4.11-1.fc20'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).

Comment 10 Fedora Update System 2014-01-11 08:48:04 UTC
dnf-0.4.11-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.