Skip to content

Improve temporary file location for atomic writes #1477

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
merged 2 commits into from
Aug 21, 2025

Conversation

jmschonfeld
Copy link
Contributor

When _amkrtemp is available (FOUNDATION_FRAMEWORK cases) we should use this before trying mktemp to create the temporary file location to preserve characteristics of the final destination like sandbox extensions. This patch adds a new use of _amkrtemp first and falls back to the existing mktemp if that fails to preserve existing behavior for failure cases. It also adds some infrastructure to include a debug description in file path errors so we can indicate the original _amkrtemp failure if both _amkrtemp and mktemp fail.

@jmschonfeld jmschonfeld requested a review from kperryua August 21, 2025 18:30
@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test Windows platform

@jmschonfeld jmschonfeld merged commit 1734c7b into swiftlang:main Aug 21, 2025
19 checks passed
@jmschonfeld jmschonfeld deleted the temp-dir-improvement branch August 21, 2025 20:53
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