Dnf fetch repo metadata twice

When installing or updating my system using dnf, it’s fetching repo metadata twice every time.

The output of dnf update:

desertsand@fedora:~$ sudo dnf update
[sudo] password for desertsand: 
Copr repo for cosmic-epoch owned by ryanabx                                                           5.7 kB/s | 1.5 kB     00:00    
Copr repo for cosmic-epoch owned by ryanabx                                                           646 kB/s | 899 kB     00:01    
Brave Browser                                                                                         6.8 kB/s | 2.0 kB     00:00    
Brave Browser                                                                                          60 kB/s |  44 kB     00:00    
Fedora 40 - x86_64                                                                                    6.5 kB/s | 3.1 kB     00:00    
Fedora 40 openh264 (From Cisco) - x86_64                                                              2.1 kB/s | 989  B     00:00    
Fedora 40 - x86_64 - Updates                                                                           11 kB/s | 4.6 kB     00:00    
Fedora 40 - x86_64 - Updates                                                                          900 kB/s | 4.7 MB     00:05    
RPM Fusion for Fedora 40 - Free                                                                       1.5 kB/s | 1.2 kB     00:00    
RPM Fusion for Fedora 40 - Free - Updates                                                              30 kB/s |  11 kB     00:00    
RPM Fusion for Fedora 40 - Free - Updates                                                              37 kB/s |  72 kB     00:01    
Terra 40                                                                                              1.4 kB/s | 1.3 kB     00:00    
Terra 40                                                                                               47 kB/s |  89 kB     00:01    
vivaldi                                                                                                12 kB/s | 3.0 kB     00:00    
vivaldi                                                                                               3.3 kB/s | 2.1 kB     00:00    
vscodium                                                                                              1.1 kB/s | 833  B     00:00    
Dependencies resolved.

My repolist:

desertsand@fedora:~$ sudo dnf repolist enabled
[sudo] password for desertsand: 
repo id                                                                repo name
brave-browser                                                          Brave Browser
copr:copr.fedorainfracloud.org:ryanabx:cosmic-epoch                    Copr repo for cosmic-epoch owned by ryanabx
fedora                                                                 Fedora 40 - x86_64
fedora-cisco-openh264                                                  Fedora 40 openh264 (From Cisco) - x86_64
gitlab.com_paulcarroty_vscodium_repo                                   vscodium
rpmfusion-free                                                         RPM Fusion for Fedora 40 - Free
rpmfusion-free-updates                                                 RPM Fusion for Fedora 40 - Free - Updates
terra                                                                  Terra 40
updates                                                                Fedora 40 - x86_64 - Updates
vivaldi                                                                vivaldi

Try that as dnf repolist the use of sudo is not required and the default is enabled.

I think what you are seeing is the first request for when it was last updated and the second is the actual metadata download. Note that not all show the duplicates.

If the metadata has not been updated since it was last checked there is no reason for a full download.

I may be wrong, but this is always the way I assumed it was done when mine shows twice like that.

I suspect the next time you use dnf (within a short time) it will not show that info at all

1 Like

Dnf first download a file containing checksums of the cached files. Then it compares these checksums with the files you already have, and if they match, no further download takes place. If they don’t match, the rest of the files needs to be downloaded as well. You can see that by the different byte counts.

Example in /var/cache/dnf/updates-02a32a5ce99e20ab you have

  • metalink.xml which is a list of mirrors and some checksum values
  • repodata/repomd.xml which has the checksums of the other files in repodata
2 Likes

You’re right, it’s just a matter of habit.

Yes, it does not show up when dnf is used shortly after.

Thanks for the answer, I think I’ve got it.