From 5e858e1259e74c49d158491df6c12c047597666a Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Tue, 23 Jan 2024 09:46:24 +0000 Subject: [PATCH] Delete file on failure in Requests and Curl-Impersonate downloaders --- devine/core/downloaders/curl_impersonate.py | 1 + devine/core/downloaders/requests.py | 1 + 2 files changed, 2 insertions(+) diff --git a/devine/core/downloaders/curl_impersonate.py b/devine/core/downloaders/curl_impersonate.py index 174f09b..2ec879f 100644 --- a/devine/core/downloaders/curl_impersonate.py +++ b/devine/core/downloaders/curl_impersonate.py @@ -96,6 +96,7 @@ def curl_impersonate( download_sizes.clear() break except Exception as e: + out_path.unlink(missing_ok=True) if DOWNLOAD_CANCELLED.is_set() or attempts == MAX_ATTEMPTS: raise e time.sleep(RETRY_WAIT) diff --git a/devine/core/downloaders/requests.py b/devine/core/downloaders/requests.py index 844c1a3..f7c4278 100644 --- a/devine/core/downloaders/requests.py +++ b/devine/core/downloaders/requests.py @@ -98,6 +98,7 @@ def requests( download_sizes.clear() break except Exception as e: + out_path.unlink(missing_ok=True) if DOWNLOAD_CANCELLED.is_set() or attempts == MAX_ATTEMPTS: raise e time.sleep(RETRY_WAIT)