Bug 1186948 - [download] data loss: dnf download should not delete files from local repositories
[download] data loss: dnf download should not delete files from local reposit...
Product: Fedora
Classification: Fedora
Component: dnf-plugins-core (Show other bugs)
Unspecified Unspecified
low Severity unspecified
: ---
: ---
Assigned To: packaging-team-maint
Fedora Extras Quality Assurance
Depends On:
Blocks: TRACKER-bugs-affecting-libguestfs supermin-dnf
  Show dependency treegraph
Reported: 2015-01-28 18:13 EST by Igor Gnatenko
Modified: 2015-05-21 09:02 EDT (History)
10 users (show)

See Also:
Fixed In Version: dnf-plugins-core-0.1.7-1.fc22
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2015-05-08 03:27:37 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Igor Gnatenko 2015-01-28 18:13:33 EST
I have repository on my local filesystem and `dnf download` crashing with OSError because it's not downloading pkg and trying to move pkg.

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 134, in _main
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1059, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python2.7/site-packages/dnf-plugins/download.py", line 94, in run
    map(move, locations)
  File "/usr/lib/python2.7/site-packages/dnf-plugins/download.py", line 196, in _move_package
OSError: [Errno 13] Permission denied: '/var/lib/dnf/plugins/local/bc-1.06.95-13.fc22.x86_64.rpm'
Comment 1 Honza Silhan 2015-02-02 05:11:47 EST
Hi Igor, what was your $PWD? Does it work with root access?
Comment 2 Igor Gnatenko 2015-02-03 11:10:26 EST
(In reply to Jan Silhan from comment #1)
> Hi Igor, what was your $PWD? Does it work with root access?
$PWD = ~/

yes, it works with root access, because it's copying rpm file from local repo (only-root-rw) and removing rpm from local repo.

it's need to be fixed in code while we checking from what repo we are downloading package and repo url =~ file://.* - don't do os.unlink()
Comment 3 Honza Silhan 2015-02-13 06:03:10 EST
Igor, if you already know how to fix this, make a PR, please. Otherwise I am giving it a low prio.
Comment 4 Jaroslav Reznik 2015-03-03 11:47:24 EST
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
Comment 5 Richard W.M. Jones 2015-04-10 13:56:42 EDT
I was just filing a bug about this, but discovered this one.

*NB* all the following commands are executed as non-root.

Create a local repository:

mkdir /tmp/repo
cd /tmp/repo
dnf download bash
createrepo .
ls -l

Observe that the local repo contains a bash-*.rpm file and the
repodata/ subdirectory.

Create a yum.conf pointing to the local repository:

mkdir /tmp/download
cd /tmp/download
cat > yum.conf <<'EOF'


Now download files using the local repository:

cd /tmp/download
dnf download -v -c yum.conf bash

The 'dnf download' command works -- that is not the issue.  However
go and look back in the /tmp/repo directory.  The dnf command has
deleted the original RPM in the local repository!

Version-Release number of selected component (if applicable):

Comment 6 Richard W.M. Jones 2015-04-10 13:57:50 EDT
(In reply to Jan Silhan from comment #3)
> Igor, if you already know how to fix this, make a PR, please. Otherwise I am
> giving it a low prio.

What is a PR?  IMO this is a very serious bug.  dnf download
should not touch original repositories.
Comment 7 Radek Holy 2015-04-13 03:41:48 EDT
Moreover, I think that the plugin should not *move* the files, it should be enough to *copy* them since dnf.Base takes care of removing the packages downloaded using "download_packages" and it already tests whether they were really downloaded or whether they are available in a local repository.
Comment 8 Michael Mráka 2015-04-14 04:40:32 EDT
Fixed in
Comment 9 Richard W.M. Jones 2015-04-14 05:00:37 EDT
I applied your test patch to dnf-plugins-core, and I can confirm that
it fixes the case outlined in comment 5.
Comment 10 Fedora Update System 2015-05-02 09:49:59 EDT
dnf-plugins-core-0.1.7-1.fc22,hawkey-0.5.5-1.fc22,dnf-1.0.0-1.fc22 has been submitted as an update for Fedora 22.
Comment 11 Fedora Update System 2015-05-03 13:24:53 EDT
Package dnf-plugins-core-0.1.7-1.fc22, hawkey-0.5.5-1.fc22, dnf-1.0.0-1.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-plugins-core-0.1.7-1.fc22 hawkey-0.5.5-1.fc22 dnf-1.0.0-1.fc22'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Comment 12 Fedora Update System 2015-05-08 03:27:37 EDT
dnf-plugins-core-0.1.7-1.fc22, hawkey-0.5.5-1.fc22, dnf-1.0.0-1.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 13 Richard W.M. Jones 2015-05-21 09:02:40 EDT
Can confirm this is fixed in

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