When extracting zip archives, os.mkdir() could raise [Errno 17] EEXIST
in two places:
1. makedirs() - A directory might already exist between the path_exists
check and the os.mkdir() call, or be created by a prior extraction step.
2. _extract_member() - makedirs() may have already created a directory
when building parent paths for a file entry, and then a separate
directory entry for the same path triggers os.mkdir() again.
Wrap both os.mkdir() calls in try/except OSError to handle this
gracefully.
Co-authored-by: Richard Taylor <RT@MacBookPro.lan>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
install_mpk() would fail with EEXIST if the destination folder already
existed from a previous (possibly partial) install, or if a dangling
symlink occupied the path (e.g. a dev symlink whose target was removed).
Before extracting, now remove the destination if it is:
- A real directory (via shutil.rmtree)
- A regular file (via os.remove)
- A symlink, including broken ones (via os.remove as a fallback)
This enables clean reinstalls, updates, and recovery from failed
installs.
Co-authored-by: Richard Taylor <RT@MacBookPro.lan>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>