From d9ab73d2a742dd03860cb2d24f3dbb42870eedbf Mon Sep 17 00:00:00 2001 From: danielmeppiel Date: Sat, 14 Mar 2026 13:24:40 +0100 Subject: [PATCH] fix: use _rmtree for Windows-safe directory cleanup in downloader Replace bare shutil.rmtree() calls with the existing _rmtree() helper that handles read-only git pack files and Windows file locks. The helper was already defined but not used in two code paths (download_package and download_subdirectory_package). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/apm_cli/deps/github_downloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apm_cli/deps/github_downloader.py b/src/apm_cli/deps/github_downloader.py index a71ebb22..ae82e1ed 100644 --- a/src/apm_cli/deps/github_downloader.py +++ b/src/apm_cli/deps/github_downloader.py @@ -1280,7 +1280,7 @@ def download_subdirectory_package(self, dep_ref: DependencyReference, target_pat # If target exists and has content, remove it if target_path.exists() and any(target_path.iterdir()): - shutil.rmtree(target_path) + _rmtree(target_path) target_path.mkdir(parents=True, exist_ok=True) # Copy subdirectory contents to target @@ -1409,7 +1409,7 @@ def download_package( # If directory already exists and has content, remove it if target_path.exists() and any(target_path.iterdir()): - shutil.rmtree(target_path) + _rmtree(target_path) target_path.mkdir(parents=True, exist_ok=True) # Store progress reporter so we can disable it after clone