Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions emsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import sys
import sysconfig
import zipfile
import time

if os.name == 'nt':
try:
import winreg
Expand Down Expand Up @@ -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)
Expand Down