Skip to content

Commit

Permalink
Fix Renaming Temporary Files
Browse files Browse the repository at this point in the history
This patch fixes the renaming of temporary files on Windows which fails
with the error that a process still has an open file handler on these
files. The process is sentinal5dl itself which did not close the file
yet.

This fixes #70
This fixes #71
  • Loading branch information
lkiesow committed Oct 2, 2021
1 parent 4321c5c commit c6b91a9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sentinel5dl/__init__.py
Expand Up @@ -109,11 +109,12 @@ def __http_request(path, filename=None, retries=9):
curl.perform()
curl.close()

if filename:
os.rename(f'{filename}.tmp', filename)
else:
if not filename:
return f.getvalue()

# rename temporary file if we downloaded one
os.rename(f'{filename}.tmp', filename)

except pycurl.error as err:
if not retries:
if filename:
Expand Down

0 comments on commit c6b91a9

Please sign in to comment.