From 36cacead7b850030abf698e039082f4f565601be Mon Sep 17 00:00:00 2001 From: vandalorian Date: Mon, 17 Mar 2025 22:10:28 +0400 Subject: [PATCH 1/3] correction of problem 402: takes into account that the file may be temporarily blocked (for example, by antivirus or another process), and tries to repeat the operation several times with an increase in waiting time. --- emsdk.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/emsdk.py b/emsdk.py index 66203b7774..54896d0b80 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,7 +609,14 @@ 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)) + 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)) + #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) From ba1f9fb26478dd487ebacd42966cd57acf39952e Mon Sep 17 00:00:00 2001 From: vandalorian Date: Wed, 19 Mar 2025 19:10:24 +0400 Subject: [PATCH 2/3] correction of problem 402 --- emsdk.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/emsdk.py b/emsdk.py index 54896d0b80..b790dbbced 100644 --- a/emsdk.py +++ b/emsdk.py @@ -615,9 +615,8 @@ def unzip(source_filename, dest_dir): break except PermissionError: print(f"Попытка {attempt + 1}/10: Файл {dst_filename} заблокирован, ждем {0.5*(attempt+1)} сек") - time.sleep(0.5*(attempt+1)) - #move_with_overwrite(fix_potentially_long_windows_pathname(dst_filename), fix_potentially_long_windows_pathname(final_dst_filename)) - + time.sleep(0.5*(attempt+1)) + if common_subdir: remove_tree(unzip_to_dir) except zipfile.BadZipfile as e: From 65e72886f178a0be7bae82ed61af15cf857e8413 Mon Sep 17 00:00:00 2001 From: vandalorian Date: Thu, 20 Mar 2025 18:48:17 +0400 Subject: [PATCH 3/3] correction of problem 402 --- emsdk.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/emsdk.py b/emsdk.py index b790dbbced..c2d99e66b9 100644 --- a/emsdk.py +++ b/emsdk.py @@ -616,9 +616,8 @@ def unzip(source_filename, dest_dir): 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) + 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)