Skip to content

Commit

Permalink
create --destdir if not exist
Browse files Browse the repository at this point in the history
fixes issue when use of --destdir without an existing directory
downloads each package on top of each other to --destdir as a file
  • Loading branch information
MichaelMraka authored and Jan Silhan committed Mar 12, 2015
1 parent 0f72f4c commit 756d61e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions plugins/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def run(self, args):
else:
dest = dnf.i18n.ucd(os.getcwd())

for pkg in locations:
self._move_package(dest, pkg)
self._move_packages(dest, locations)

def _download_rpms(self, pkg_specs):
"""Download packages to dnf cache."""
Expand Down Expand Up @@ -196,8 +195,11 @@ def _get_query_source(self, pkg_spec):
return q

@staticmethod
def _move_package(target, location):
def _move_packages(target, locations):
"""Move the downloaded package to target."""
shutil.copy(location, target)
os.unlink(location)
if not os.path.exists(target):
os.makedirs(target)
for pkg in locations:
shutil.copy(pkg, target)
os.unlink(pkg)
return target

0 comments on commit 756d61e

Please sign in to comment.