Commit fa602ec
Lukas Puehringer
Allow modifying pep images with same name
Currently, 'peps.converters.add_pep_image' does not allow to add an
image that already exists in the database for the same name. As a
consequence images cannot be updated.
This commit 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
Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>1 parent 6902c19 commit fa602ec
1 file changed
+10
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
224 | | - | |
225 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
226 | 234 | | |
227 | 235 | | |
228 | 236 | | |
| |||
0 commit comments