proposed solution for #45

This commit is contained in:
Mahmoud Hashemi 2015-07-30 23:34:42 -07:00
parent a060a8abd5
commit b71f8eb5dd
1 changed files with 4 additions and 2 deletions

View File

@ -265,8 +265,9 @@ class AtomicSaver(object):
raise OSError(errno.EEXIST,
'Overwrite disabled and file already exists',
self.dest_path)
_, tmp_part_path = tempfile.mkstemp(dir=self.dest_dir,
text=self.text_mode)
tmp_fd, tmp_part_path = tempfile.mkstemp(dir=self.dest_dir,
text=self.text_mode)
os.close(tmp_fd)
try:
_atomic_rename(tmp_part_path, self.part_path,
overwrite=self.overwrite_part)
@ -282,6 +283,7 @@ class AtomicSaver(object):
return self.part_file
def __exit__(self, exc_type, exc_val, exc_tb):
self.part_file.close()
if exc_type:
if self.rm_part_on_exc:
try: