Commit 033512a3 authored by Marius Gedminas's avatar Marius Gedminas

Fix ResourceWarnings in FileStorage.pack()

parent b07519b5
......@@ -1034,10 +1034,13 @@ class FileStorage(
# want to invest much in the old packer, at least for now.
assert referencesf is not None
p = FileStoragePacker(storage, referencesf, stop, gc)
try:
opos = p.pack()
if opos is None:
return None
return opos, p.index
finally:
p.close()
def pack(self, t, referencesf, gc=None):
"""Copy data from the current database file to a packed file
......
......@@ -382,6 +382,15 @@ class FileStoragePacker(FileStorageFormatter):
self.toid2tid = {}
self.toid2tid_delete = {}
self._tfile = None
def close(self):
self._file.close()
if self._tfile is not None:
self._tfile.close()
if self.blob_removed is not None:
self.blob_removed.close()
def pack(self):
# Pack copies all data reachable at the pack time or later.
#
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment