Downloader: Cleanup on exception
Otherwise a file exists error will show up if any exception happens but cancel. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
e4084b15c1
commit
ae75db1829
1 changed files with 5 additions and 1 deletions
|
|
@ -171,7 +171,7 @@ async def hf_repo_download(
|
|||
logger.info(f"Finished download for {repo_id}")
|
||||
|
||||
return download_path
|
||||
except asyncio.CancelledError:
|
||||
except (asyncio.CancelledError, Exception) as exc:
|
||||
# Cleanup on cancel
|
||||
if download_path.is_dir():
|
||||
shutil.rmtree(download_path)
|
||||
|
|
@ -180,3 +180,7 @@ async def hf_repo_download(
|
|||
|
||||
# Stop the progress bar
|
||||
progress.stop()
|
||||
|
||||
# Re-raise exception if the task isn't cancelled
|
||||
if not isinstance(exc, asyncio.CancelledError):
|
||||
raise exc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue