diff --git a/emsdk.py b/emsdk.py index 66203b7774..c2d99e66b9 100644 --- a/emsdk.py +++ b/emsdk.py @@ -21,6 +21,8 @@ import sys import sysconfig import zipfile +import time + if os.name == 'nt': try: import winreg @@ -607,10 +609,15 @@ def unzip(source_filename, dest_dir): parent_dir = os.path.dirname(fix_potentially_long_windows_pathname(final_dst_filename)) if parent_dir and not os.path.exists(parent_dir): os.makedirs(parent_dir) - move_with_overwrite(fix_potentially_long_windows_pathname(dst_filename), fix_potentially_long_windows_pathname(final_dst_filename)) - - if common_subdir: - remove_tree(unzip_to_dir) + for attempt in range(10): + try: + move_with_overwrite(fix_potentially_long_windows_pathname(dst_filename), fix_potentially_long_windows_pathname(final_dst_filename)) + break + except PermissionError: + print(f"Попытка {attempt + 1}/10: Файл {dst_filename} заблокирован, ждем {0.5*(attempt+1)} сек") + time.sleep(0.5*(attempt+1)) + if common_subdir: + remove_tree(unzip_to_dir) except zipfile.BadZipfile as e: errlog("Unzipping file '" + source_filename + "' failed due to reason: " + str(e) + "! Removing the corrupted zip file.") rmfile(source_filename)