lukpueh
(Lukas Puehringer)
February 12, 2020, 5:22pm
109
I replaced the table image (pep-0458-1.png
) with an actual table in secure-systems-lab/peps/#73 and renamed pep-0458-2.png
→ pep-0458-1.png
, which confused the pep converter. Apparently this was a known issue, and I think I found a fix for it:
python:main
← lukpueh:allow-modify-pep-image
opened 05:12PM - 12 Feb 20 UTC
Fixes #824
Currently, `peps.converters.add_pep_image` does not allow to add a… n image that already exists in the database for the same name. As a consequence images cannot be updated.
This PR modifies `peps.converters.add_pep_image` to also update the image db record if the corresponding file has changed as per `filecmp.cmp'` This requires removing the file prior to the db update, because the django `FileField` does not override existing files.
Alternatives to the ad hoc removal of the file in `add_pep_image` include passing a custom `OverwriteStorage` to the used `ImageField`, see e.g.:
https://code.djangoproject.com/ticket/4339
https://stackoverflow.com/questions/9522759/imagefield-overwrite-image-file-with-same-name
2 Likes