Skip to content

Commit efef91b

Browse files
authored
Merge pull request #79 from Frawless/create-image-dir-if-not-exists
Create images directory for openstack image download if it doesn't exists
2 parents 4f853aa + 881eb00 commit efef91b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: osia/installer/downloader/image.py

+8
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,13 @@ def download_image(image_url: str, image_file: str):
8484
"""Main entrypoint for image download, function
8585
extracts url to rhcos image, downloads and extracts it
8686
to specified target"""
87+
directory = Path(image_file).parent
88+
# Check if the directory exists
89+
if not directory.exists():
90+
# If the directory does not exist, create it
91+
directory.mkdir(parents=True)
92+
logging.debug("Creating %s directory for download images", directory)
93+
else:
94+
logging.debug("Directory %s for images already exists", directory)
8795
res_file = get_data(image_url, image_file, _extract_gzip)
8896
return res_file

0 commit comments

Comments
 (0)