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

Added support to immediately delete Xcode and its XIPs #211

Merged
merged 3 commits into from
Sep 18, 2022

Conversation

juanjonol
Copy link
Contributor

Added a new --empty-trash flag to xcodes install and xcodes uninstall, to completely delete Xcode's .xip or the app itself instead of keeping it on the user's Trash.

This closes #185.

After Pull Request XcodesOrg#60, `xcodes` always moves Xcode's .xip to the Trash after installation. This is problematic for scripts, because on modern macOS versions, [Full Disk Access is required to programatically delete the Trash](https://apple.stackexchange.com/questions/376916/cannot-ls-trash-in-the-terminal-in-catalina-operation-not-permitted).

To solve this without reducing security, added a new `--delete-xip` flag that automatically deletes the .xip after a successful installation.

- This is done this way to preserve the current behaviour (moving the .xip to the Trash) by default, [as it was originally intended](XcodesOrg#56 (comment)).

This closes XcodesOrg#185.
This is equivalent to the `--delete-xip` flag that was added to `xcodes install` on the previous commit.
This two flags do essentially the same thing (skip the Trash and irrevocably delete Xcode or its .xip) so it makes sense to use the same name for both.

- Although the Trash isn't really "emptied" (the files never get to the Trash in the first place), this is the most intuitively way I've found to refer to this at a high level.
- Alternatives considered:
   - `--skip-trash`. This explains better the current implementation, but I think it's more ambiguous: if the user doesn't know that by default files are moved to the Trash, "skip Trash" could be understood as "skip deleting files from the Trash"...
   - `--delete-immediately` (the way Finder refers to deleting a single file from the Trash). This is longer to type, and "immediately" could imply that, without this flag, files will be automatically deleted in the future somehow.
@juanjonol juanjonol requested a review from a team as a code owner September 10, 2022 16:11
@MattKiazyk MattKiazyk merged commit 3ddb27c into XcodesOrg:main Sep 18, 2022
@MattKiazyk
Copy link
Contributor

Thanks @juanjonol

@MattKiazyk MattKiazyk added the enhancement New feature or request label Sep 18, 2022
juanjonol added a commit to juanjonol/Xcode-Update that referenced this pull request Sep 18, 2022
I use `xcode-update` with a different user that the one I'm logged in on Finder, so emptying the Trash after each installation was a PITA.

- See `xcodes` Pull Request #211, “Added support to immediately delete Xcode and its XIPs”: XcodesOrg/xcodes#211
juanjonol added a commit to juanjonol/Xcode-Update that referenced this pull request Sep 18, 2022
Functionality-wise this is virtually the same, but:

- `xcodes` uses Apple's [`removeItem`](https://developer.apple.com/documentation/foundation/filemanager/1413590-removeitem) API, which _theoretically_ could had additional features over a raw `rm` (leverage APFS features, maybe remove Xcode from macOS Launch Services...).
- This slightly improves `xcode-update` output: for example, instead of showing `- <PATH_TO_XCODE>/Xcode-14.0.0-Beta.6.app will be deleted.` now it will show `- Xcode 14.0 Beta 6 (14A5294g) will be deleted.`

I can use `xcodes uninstall` for this now only because the `--empty-trash` parameter was added.

- See `xcodes` Pull Request #211, “Added support to immediately delete Xcode and its XIPs”: XcodesOrg/xcodes#211
- I explicitly want to completely delete Xcode (not to move it to the Trash) for the same reasons I did "Added support to automatically delete Xcode's .xip after installation" (7382b7e) and also because deleting Xcode using Finder is a extremely slow operation...

With this change, we no longer can verify `xcode-update` has permissions to delete the Xcode version selected... I think this is an acceptable compromise, because `xcodes uninstall` should check for permissions more thoughtfully than I did, but if it doesn't maybe I'll have to revert this commit...

- See commit “Added check to ensure the current user has permissions to delete Xcode versions” (9a0bb30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the ability to delete the xip file completely
2 participants