Skip to content

fix: change permissions of read-only files before extracting in cache restore (#20241) - #20249

Open
ChickenisLegit wants to merge 1 commit into
conan-io:develop2from
ChickenisLegit:fix/cache-restore-readonly-windows
Open

fix: change permissions of read-only files before extracting in cache restore (#20241)#20249
ChickenisLegit wants to merge 1 commit into
conan-io:develop2from
ChickenisLegit:fix/cache-restore-readonly-windows

Conversation

@ChickenisLegit

Copy link
Copy Markdown

Closes #20241.

This PR fixes a PermissionError that occurs on Windows when running conan cache restore to extract an archive that contains read-only files (e.g., from an MSYS2 environment or a Git pack idx). Python's tarfile.extractall() is unable to overwrite these existing read-only files if they already exist in the cache folder, which causes the restore process to fail with PermissionError: [Errno 13] Permission denied.

Changes

  • Updated conan/api/subapi/cache.py to iterate through the members of the tar archive and explicitly set the read/write permissions (os.chmod(target_path, stat.S_IWRITE | stat.S_IREAD)) on existing files in the cache destination before extractall() attempts to overwrite them.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ChickenisLegit

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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.

[bug] PermissionError during conan cache restore when extracting read-only files on Windows

2 participants