Skip to content

Fix EEXIST errors in zipfile.py during extraction#54

Merged
ThomasFarstrike merged 1 commit intoMicroPythonOS:mainfrom
bitcoin3us:fix/zipfile-eexist-on-extract
Feb 21, 2026
Merged

Fix EEXIST errors in zipfile.py during extraction#54
ThomasFarstrike merged 1 commit intoMicroPythonOS:mainfrom
bitcoin3us:fix/zipfile-eexist-on-extract

Conversation

@bitcoin3us
Copy link
Copy Markdown
Contributor

Summary

  • Wraps os.mkdir() in makedirs() and _extract_member() with try/except OSError to prevent [Errno 17] EEXIST crashes during zip extraction
  • The error occurs when a directory is created by makedirs() for a file's parent path, and then a separate directory entry for the same path triggers os.mkdir() again
  • Also handles the case where makedirs() races between its path_exists() check and the os.mkdir() call

Test plan

  • Install an app from the App Store that was not previously installed
  • Install an app from the App Store that was previously installed (update/reinstall)
  • Install an app after a previously failed installation left a partial directory

🤖 Generated with Claude Code

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: Claude Opus 4.6 <[email protected]>
@ThomasFarstrike
Copy link
Copy Markdown
Contributor

I haven't noticed this issue, as it's doing a "check if exists" before trying, no? But okay...

@ThomasFarstrike ThomasFarstrike merged commit d3e0099 into MicroPythonOS:main Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants