Fix: close the uploaded logo image with a context manager when sanitizing

This commit is contained in:
Trenton H committed 2026-11-26 14:11:44 -08:00
1 parent f775b94cd6
commit 8c19dcd412
1 file changed
+1 -4
+1 -4
View File
@@ -296,9 +296,8 @@ class ApplicationConfigurationSerializer(
return super().update(instance, validated_data)
def _sanitize_raster_image(self, file: UploadedFile) -> UploadedFile:
try:
with Image.open(file) as image:
data = BytesIO()
image = Image.open(file)
image.save(data, format=image.format)
data.seek(0)
@@ -310,8 +309,6 @@ class ApplicationConfigurationSerializer(
size=data.getbuffer().nbytes,
charset=getattr(file, "charset", None),
)
finally:
image.close()
def validate_app_logo(self, file: UploadedFile):
"""