fix: change permissions of read-only files before extracting in cache restore (#20241) - #20249
ChickenisLegit wants to merge 1 commit into
Conversation
|
|
|
I have read the CLA Document and I hereby sign the CLA |
|
Thanks for your contribution @ChickenisLegit Note that @danimtb has opened a new PR in #20254 that will cover this issue too, besides other possible fix, and some unit tests too to cover it, which are necessary for the code to be merged. Also, for other occasions, it is not enough to comment saying that you are signing the CLA, it is necessary to do the full CLA signing via the application, because that keeps an external track of the signings. Many thanks! |
Closes #20241.
This PR fixes a
PermissionErrorthat occurs on Windows when runningconan cache restoreto extract an archive that contains read-only files (e.g., from an MSYS2 environment or a Git pack idx). Python'starfile.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 withPermissionError: [Errno 13] Permission denied.Changes
conan/api/subapi/cache.pyto 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 beforeextractall()attempts to overwrite them.