torchbox / wagtail-wordpress-import

A package for Wagtail CMS to import WordPress blog content from an XML file into Wagtail
MIT License
44 stars 16 forks source link

`get_or_save_image` can fail if the downloaded image's is corrupted #145

Open fabienheureux opened 2 years ago

fabienheureux commented 2 years ago

This image https://limonadier.net/wp-content/uploads/2019/09/IMG_1782.jpg appears to be corrupted, but returns a 200 in get_or_save_image function.

This causes django to raise an integrity error because its width is 0 pixel

psycopg2.errors.NotNullViolation: null value in column "width" of relation "wagtailimages_image" violates not-null constraint

IMG_1782

fabienheureux commented 2 years ago

Here is a potential fix https://github.com/torchbox/wagtail-wordpress-import/pull/146 (still in draft)

Let me know what you think of this approach

nickmoreton commented 2 years ago

The example image seems to be unavailable now.

If you can complete the PR I'd be happy to review it. Thanks