From 2b0439c4be5ece5be53020bce6987d7d7e26355e Mon Sep 17 00:00:00 2001 From: toastedcornflakes <toastedcornflakes@gmail.com> Date: Tue, 11 Oct 2016 23:03:05 +0200 Subject: [PATCH] Improve robustness of LFW dataset downloader (#6112) --- sklearn/datasets/lfw.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sklearn/datasets/lfw.py b/sklearn/datasets/lfw.py index a8298cb52a..af6503f14d 100644 --- a/sklearn/datasets/lfw.py +++ b/sklearn/datasets/lfw.py @@ -23,7 +23,7 @@ detector from various online websites. # Copyright (c) 2011 Olivier Grisel <olivier.grisel@ensta.org> # License: BSD 3 clause -from os import listdir, makedirs, remove +from os import listdir, makedirs, remove, rename from os.path import join, exists, isdir from sklearn.utils import deprecated @@ -98,9 +98,11 @@ def check_fetch_lfw(data_home=None, funneled=True, download_if_missing=True): if not exists(archive_path): if download_if_missing: + archive_path_temp = archive_path + ".tmp" logger.warning("Downloading LFW data (~200MB): %s", archive_url) - urllib.urlretrieve(archive_url, archive_path) + urllib.urlretrieve(archive_url, archive_path_temp) + rename(archive_path_temp, archive_path) else: raise IOError("%s is missing" % target_filepath) -- GitLab