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

Fix ResourceWarnings in FileStorage.pack()

parent b07519b5
...@@ -1034,10 +1034,13 @@ class FileStorage( ...@@ -1034,10 +1034,13 @@ class FileStorage(
# want to invest much in the old packer, at least for now. # want to invest much in the old packer, at least for now.
assert referencesf is not None assert referencesf is not None
p = FileStoragePacker(storage, referencesf, stop, gc) p = FileStoragePacker(storage, referencesf, stop, gc)
opos = p.pack() try:
if opos is None: opos = p.pack()
return None if opos is None:
return opos, p.index return None
return opos, p.index
finally:
p.close()
def pack(self, t, referencesf, gc=None): def pack(self, t, referencesf, gc=None):
"""Copy data from the current database file to a packed file """Copy data from the current database file to a packed file
......
...@@ -382,6 +382,15 @@ class FileStoragePacker(FileStorageFormatter): ...@@ -382,6 +382,15 @@ class FileStoragePacker(FileStorageFormatter):
self.toid2tid = {} self.toid2tid = {}
self.toid2tid_delete = {} 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): def pack(self):
# Pack copies all data reachable at the pack time or later. # 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