diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 2106fcad8f..3a151166e7 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -595,7 +595,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): if f is None: continue with tempfile.SpooledTemporaryFile(max_size=100*(1024**2)) as stream: - shutil.copyfileobj(f, stream) + with f: + shutil.copyfileobj(f, stream) stream.seek(0) self.add_format(id, format, stream, index_is_id=True, path=tpath, notify=False)