Update CMS image-download script to make the appropriate expected target directories if they don't exist already

This commit is contained in:
Steve Jalim 2024-09-30 11:59:24 +01:00 коммит произвёл Alex Gibson
Родитель 83a8df6cdc
Коммит 3f9eeee68b
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -64,6 +64,16 @@ class Command(BaseCommand):
image_key = f"media/cms/{image.file.name}"
local_dest = build_path(settings.MEDIA_ROOT, image.file.name)
expected_output_dirs = [
os.path.join(settings.MEDIA_ROOT, "original_images"),
os.path.join(settings.MEDIA_ROOT, "images"),
]
for dir_path in expected_output_dirs:
if not os.path.exists(dir_path):
self.stdout.write(f"setting up: {dir_path}\n")
os.makedirs(dir_path)
if os.path.exists(local_dest) and not redownload:
self.stdout.write(f"Skipping: {local_dest} already exists locally.\n")
else: