nicer mobi icon
[wolnelektury.git] / apps / catalogue / utils.py
index 369656e..3a8d1b0 100644 (file)
@@ -55,8 +55,8 @@ class ExistingFile(UploadedFile):
         pass
 
 
-class BookImportDocProvider(DocProvider):
-    """Used for joined EPUB and PDF files."""
+class ORMDocProvider(DocProvider):
+    """Used for getting books' children."""
 
     def __init__(self, book):
         self.book = book
@@ -108,9 +108,12 @@ def create_zip(paths, zip_slug):
 
     with LockFile(zip_path, zip_slug):
         if not path.exists(path.join(zip_path, zip_filename)):
-            with ZipFile(path.join(zip_path, zip_filename), 'w') as zipf:
+            zipf = ZipFile(path.join(zip_path, zip_filename), 'w')
+            try:
                 for p in paths:
                     zipf.write(p, path.basename(p))
+            finally:
+                zipf.close()
 
         return 'zip/' + zip_filename