Replace manual trash implementation with NSFileManager's trashItemAtURL#2781
Merged
lucasderraugh merged 1 commit intoJun 4, 2026
Conversation
Contributor
Author
|
Regarding this, it was a false alarm. It's all good now. |
lucasderraugh
approved these changes
Jun 3, 2026
lucasderraugh
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the custom move-to-trash logic in
GCFoundation.mwith the system-providedNSFileManager.trashItemAtURL:resultingItemURL:error:API (available since macOS 10.8).Motivation
The previous implementation manually resolved the Trash directory, built a unique destination filename via a while-loop, and performed a file move. This had several issues:
.Trashes, forcing expensive cross-volume copy+delete operations.stringByAppendingPathExtension:@""could produce a trailing dot in the filename.Changes
GitUpKit/Core/GCFoundation.m: Replaced the 12-line manual implementation with a single call totrashItemAtURL:resultingItemURL:error:.Risk Assessment
NSErrordomain/codes instead of the previous generic error for "Unable to find Trash". Callers that inspect error details (not just success/failure) may see different error objects.trashItemAtURL:works correctly in sandboxed apps — the app already has the entitlement to access the file being trashed. No change needed.Overall this is a low-risk change — it delegates to the same system mechanism that Finder uses, and the deployment target is well above the API's availability.