From b646cef3794f2e39595778be5e14744e69684b82 Mon Sep 17 00:00:00 2001 From: Alessandro Banfi Date: Tue, 17 Mar 2015 22:27:20 +0000 Subject: [PATCH] Fixed a compatibility issue with `force download` default value setted to `true` under Windows. --- command_line.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/command_line.py b/command_line.py index 4c03ac3..31b14b8 100644 --- a/command_line.py +++ b/command_line.py @@ -775,7 +775,15 @@ class CommandBase(object): self.progress_text = '\nDone downloading.\n' f.close() - os.rename(tmp_file, file_name) + try: + os.rename(tmp_file, file_name) + except OSError: + if sys.platform.startswith('win32') and not(os.path.isdir(file_name)): + os.remove(file_name) + os.rename(tmp_file, file_name) + else: + os.remove(tmp_file) + raise OSError return self.continue_downloading_or_extract()