Commit 5f5bf797 by hlu1 Committed by Tianqi Chen

[Bugfix] Check file exists before removing it (#3178)

parent 8cb9ee47
......@@ -111,7 +111,8 @@ def download(url, path, overwrite=False, size_compare=False, verbose=1, retries=
except Exception as err:
retries -= 1
if retries == 0:
os.remove(tempfile)
if os.path.exists(tempfile):
os.remove(tempfile)
raise err
else:
print("download failed due to {}, retrying, {} attempt{} left"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment