X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/21de3884f82ce6c9b2d538d8d63c41cf68c9bae7..a7a0a535382be1fd706c3faca3a81201978ba587:/src/catalogue/fields.py?ds=sidebyside

diff --git a/src/catalogue/fields.py b/src/catalogue/fields.py
index 56de8c6da..c592c5504 100644
--- a/src/catalogue/fields.py
+++ b/src/catalogue/fields.py
@@ -173,7 +173,8 @@ class EbookField(models.FileField):
         out = self.transform(
             book.wldocument2() if self.librarian2_api else book.wldocument(),
         )
-        fieldfile.save(None, File(open(out.get_filename(), 'rb')), save=False)
+        with open(out.get_filename(), 'rb') as f:
+            fieldfile.save(None, File(f), save=False)
         self.set_file_permissions(fieldfile)
         if book.pk is not None:
             book.save(update_fields=[self.attname])