ascoderu / xtarfile

Wrapper around tarfile to add support for more compression formats
Apache License 2.0
8 stars 5 forks source link

Fixed bug with NamedTemporaryFile on Windows #4

Closed mrmichaeladavis closed 4 years ago

mrmichaeladavis commented 4 years ago

Changed NamedTemporaryFile to be manually deleted isntead of automatic. We delete it manually because otherwise on Windows it gets deleted before we the temp file is saved to the output file location. This is because on Windows, file handles with the O_TEMPORARY flag (which is set if we pass delete=True) are deleted as soon as they're closed.

See the docs at https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile

"Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If delete is true (the default), the file is deleted as soon as it is closed. The returned object is always a file-like object whose file attribute is the underlying true file object. This file-like object can be used in a with statement, just like a normal file."

c-w commented 4 years ago

This fix has been released in version 0.0.4.