summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2022-07-13 14:28:25 +0300
committerAarni Koskela <akx@iki.fi>2022-07-13 14:28:25 +0300
commit681550eb2c2fe790b17d2c79590f8f5097eb8557 (patch)
treeb0a47621f06d6ec6c50b4a772e5f68008e5092f5 /scripts
parent4c837f152652e273e6319d1569ba7e638eda14d2 (diff)
downloadbabel-681550eb2c2fe790b17d2c79590f8f5097eb8557.tar.gz
Downloader: download to temporary file, then replace
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/download_import_cldr.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/scripts/download_import_cldr.py b/scripts/download_import_cldr.py
index 2cdb1fc..3ddd9b4 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')