diff --git a/sklearn/datasets/lfw.py b/sklearn/datasets/lfw.py index a8298cb52a06f05e3355a7d863c6ab78c3c92bae..af6503f14d7d14be90a7b682ef4d6bcccf64b4ce 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)