Skip to content

Commit

Permalink
Allow local downloads to same downloaddir
Browse files Browse the repository at this point in the history
Currently when `dnf download --downloaddir <dir> <package>` sources`<package>` from `<dir>` it triggers a `shutil.SameFileError` exception and aborts the entire download process.

This goes against the current flow which marks locally present RPMs that match a remote RPM as `[SKIPPED] <package>.rpm: Already downloaded`.

This change allows downloads of locally sourced packages to the same file, treating it as a no-op.
  • Loading branch information
nicbadiu authored and m-blaha committed Jul 3, 2024
1 parent b06dca1 commit dee3952
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dnf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,10 @@ def download_packages(self, pkglist, progress=None, callback_total=None):
pkg.location.lstrip("/"))
else:
location = os.path.join(pkg.repo.pkgdir, pkg.location.lstrip("/"))
shutil.copy(location, self.conf.destdir)
try:
shutil.copy(location, self.conf.destdir)
except shutil.SameFileError:
pass

def add_remote_rpms(self, path_list, strict=True, progress=None):
# :api
Expand Down

0 comments on commit dee3952

Please sign in to comment.