Browse Source

Fix #384.

Also clean up some potential resource leaking around exporter crashes.
pull/392/head
Adam Johnson 1 year ago
parent
commit
338a049ef4
  1. 11
      korman/exporter/outfile.py

11
korman/exporter/outfile.py

@ -264,11 +264,6 @@ class OutputFiles:
except: except:
raise raise
else: else:
# Must call the EncryptedStream close to actually encrypt the data
stream.close()
if not stream is backing_stream:
backing_stream.close()
# Not passing enc as a keyword argument to the output file definition. It makes more # Not passing enc as a keyword argument to the output file definition. It makes more
# sense to yield an encrypted stream from this context manager and encrypt as we go # sense to yield an encrypted stream from this context manager and encrypt as we go
# instead of doing lots of buffer copying to encrypt as a post step. # instead of doing lots of buffer copying to encrypt as a post step.
@ -286,6 +281,12 @@ class OutputFiles:
else: else:
kwargs["file_path"] = file_path kwargs["file_path"] = file_path
self._files.add(_OutputFile(**kwargs)) self._files.add(_OutputFile(**kwargs))
finally:
# Must call the EncryptedStream close to actually encrypt the data
if isinstance(stream, plEncryptedStream):
stream.close()
if isinstance(backing_stream, hsFileStream):
backing_stream.close()
def _generate_files(self, func=None): def _generate_files(self, func=None):
dat_only = self._exporter().dat_only dat_only = self._exporter().dat_only

Loading…
Cancel
Save