Fix #792311 (Calibre does not release file handles)

This commit is contained in:
Kovid Goyal 2011-06-03 08:38:01 -06:00
parent b5d59eb1bc
commit 9055b68051

View File

@ -595,7 +595,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
if f is None: if f is None:
continue continue
with tempfile.SpooledTemporaryFile(max_size=100*(1024**2)) as stream: with tempfile.SpooledTemporaryFile(max_size=100*(1024**2)) as stream:
shutil.copyfileobj(f, stream) with f:
shutil.copyfileobj(f, stream)
stream.seek(0) stream.seek(0)
self.add_format(id, format, stream, index_is_id=True, self.add_format(id, format, stream, index_is_id=True,
path=tpath, notify=False) path=tpath, notify=False)