Skip to content

Commit

Permalink
Merge pull request #79 from Frawless/create-image-dir-if-not-exists
Browse files Browse the repository at this point in the history
Create images directory for openstack image download if it doesn't exists
  • Loading branch information
mijaros authored May 22, 2024
2 parents 4f853aa + 881eb00 commit efef91b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions osia/installer/downloader/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,13 @@ def download_image(image_url: str, image_file: str):
"""Main entrypoint for image download, function
extracts url to rhcos image, downloads and extracts it
to specified target"""
directory = Path(image_file).parent
# Check if the directory exists
if not directory.exists():
# If the directory does not exist, create it
directory.mkdir(parents=True)
logging.debug("Creating %s directory for download images", directory)
else:
logging.debug("Directory %s for images already exists", directory)
res_file = get_data(image_url, image_file, _extract_gzip)
return res_file

0 comments on commit efef91b

Please sign in to comment.