Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cask/artifact/moved: fix permission handling when removing directories #16894

Merged
merged 1 commit into from Mar 18, 2024

Conversation

Bo98
Copy link
Member

@Bo98 Bo98 commented Mar 15, 2024

While target.parent.writable? is a sufficient check if we can remove a file or an empty directory, it is insufficient to test whether we can remove the entire directory tree as the directory itself and all non-empty recursive subdirectories will need write permissions. Utils.gain_permissions_remove already handles this for us so use it unconditionally.

Note that using Utils.gain_permissions_remove doesn't mean that sudo will always be used - it will still try to remove without sudo if possible.

@Bo98
Copy link
Member Author

Bo98 commented Mar 15, 2024

Not entirely sure why there's a test that expects uninstalling to fail? Seems really weird to be perfectly ok raising permission if the parent directory isn't writable but not if a child directory is.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks @Bo98!

@MikeMcQuaid
Copy link
Member

Seems really weird to be perfectly ok raising permission if the parent directory isn't writable but not if a child directory is.

Agreed.

@Bo98 Bo98 merged commit 6cb0fd0 into master Mar 18, 2024
26 checks passed
@Bo98 Bo98 deleted the cask-fix-app-remove branch March 18, 2024 14:42
@github-actions github-actions bot added the outdated PR was locked due to age label Apr 18, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants