Skip to content

Commit

Permalink
chore: cleanup temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Apr 17, 2024
1 parent ead3c86 commit c6ddbf4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/kiara_plugin/onboarding/modules/download/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ def retrieve_archive(
suffix = ""

tmp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix)
atexit.register(tmp_file.close)

def rm_tmp_file():
tmp_file.close()
os.unlink(tmp_file.name)

atexit.register(rm_tmp_file)
kiara_file: KiaraFile

kiara_file = download_file( # type: ignore
Expand Down
9 changes: 7 additions & 2 deletions src/kiara_plugin/onboarding/utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,15 @@ def download_file_bundle(
suffix = ""

tmp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix)
atexit.register(tmp_file.close)

def rm_tmp_file():
tmp_file.close()
os.unlink(tmp_file.name)

atexit.register(rm_tmp_file)

history = []
datetime.utcnow().replace(tzinfo=pytz.utc)
# datetime.utcnow().replace(tzinfo=pytz.utc)
with open(tmp_file.name, "wb") as f:
with httpx.stream("GET", url, follow_redirects=True) as r:
history.append(dict(r.headers))
Expand Down

0 comments on commit c6ddbf4

Please sign in to comment.