Skip to content

Avoid attaching removefile callbacks when delegate does not implement functions #1070

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

Merged

Conversation

jmschonfeld
Copy link
Contributor

The previous ObjC implementation of -[NSFileManager removeItemAtPath:] only attached callbacks to the removefile_state_t when the delegate was present and it implemented the equivalent functions. However, the new Swift implementation unconditionally attaches callbacks that simply return "default" values when no delegate responds. This causes a behavioral difference in removefile when removing items that are not materialized (ex. remote iCloud documents that do not currently exist on disk). Calling the confirm callback requires iterating the children of the removed directory and performing this iteration causes removefile to materialize the file on-disk. We should avoid this materialization when no callback exists - this change does this by only attaching callbacks to the removefile_state_t when we have a delegate that actually cares.

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit 86d660b into swiftlang:main Dec 5, 2024
3 checks passed
@jmschonfeld jmschonfeld deleted the fm-removefile-materialization branch December 5, 2024 01:24
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.

2 participants