Skip to content

Commit

Permalink
When redownloading images, ensure that renditions are recreated
Browse files Browse the repository at this point in the history
...by deleting any local DB records related to them.

This basically wipes all renditions, which is fine for local dev as they
can be auto-created on the fly locally, unlike in prod
  • Loading branch information
stevejalim authored and alexgibson committed Sep 30, 2024
1 parent 985b9a8 commit 2df9c9b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bedrock/cms/management/commands/download_media_to_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def handle(self, *args, **options):
blob = bucket.blob(image_key)
blob.download_to_filename(local_dest)
self.stdout.write(f"Downloaded {image_key} from {bucket_name} to {local_dest}\n")

if redownload:
# The DB will still think it has renditions included, and we want to regenerate those
self.stdout.write(f"Deleting DB records of old renditions for {image_key}\n")
image.renditions.all().delete()
image._pre_generate_expected_renditions()
self.stdout.write("Triggered local generation of renditions\n")

Expand Down

0 comments on commit 2df9c9b

Please sign in to comment.