From: Aarni Koskela Date: Wed, 13 Jul 2022 11:28:25 +0000 (+0300) Subject: Downloader: download to temporary file, then replace X-Git-Tag: v2.11.0~13^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=681550eb2c2fe790b17d2c79590f8f5097eb8557;p=thirdparty%2Fbabel.git Downloader: download to temporary file, then replace --- diff --git a/scripts/download_import_cldr.py b/scripts/download_import_cldr.py index 2cdb1fc4..3ddd9b47 100755 --- a/scripts/download_import_cldr.py +++ b/scripts/download_import_cldr.py @@ -64,9 +64,9 @@ def main(): while not is_good_file(zip_path): log("Downloading '%s' from %s", FILENAME, URL) - if os.path.isfile(zip_path): - os.remove(zip_path) - urlretrieve(URL, zip_path, (reporthook if show_progress else None)) + tmp_path = f"{zip_path}.tmp" + urlretrieve(URL, tmp_path, (reporthook if show_progress else None)) + os.replace(tmp_path, zip_path) changed = True print() common_path = os.path.join(cldr_path, 'common')