-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix GetTempFileName() on Windows #74855
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsFix #73793
That's with the best situation, where there's no existing temp files. When the temp folder is nearly full, the existing API deteriorates substantially:
This API will be hidden as part of #72881, but a great deal of code has been written to use it and that code will become faster/more robust. Incidentally, in testing this I filled up the temp folder and (with the previous implementation) Benchmark .NET crashed. That will now be fixed.
|
src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.Extensions/tests/System/IO/PathTests.cs
Outdated
Show resolved
Hide resolved
Updated.
for convenience, the above includes the cleanup: |
src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
Outdated
Show resolved
Hide resolved
I think this is good to go. It does feel like this and GetTempFileName ideally would use 36 not 32 chars, giving another 4000 possibilities. I can change both if folks want. But 1 billion is a lot better than 65K. |
src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
Outdated
Show resolved
Hide resolved
Addressed feedback again. |
src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.Extensions/tests/System/IO/PathTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.Extensions/tests/System/IO/PathTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.Extensions/tests/System/IO/PathTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This is great. Now we can recommend using this API without having to add the caveat of "on Windows this is limited to 65K files".
We should also be sure to update the docs to remove that part for .NET 8:
https://docs.microsoft.com/en-us/dotnet/api/system.io.path.gettempfilename
The GetTempFileName method will raise an IOException if it is used to create more than 65535 files without deleting previous temporary files.
src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
Outdated
Show resolved
Hide resolved
I think everything's addressed, unless you want me to remove the ToLowerInvariant. |
I mean, only if you care about saving the trees. |
@stephentoub I noticed that GetTempFileName() on Unix throws FileNotFoundException when TMPDIR is bad. Windows throws DirectoryNotFoundException when TMP is bad. I fixed Unix - LMK if you have concerns. Perhaps a breaking change note to make. where TMPDIR was /tmp/tmp7xcc3h.tmp/ it was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @danmoseley !
Failures are QUIC and LibrariesInteropGenerator |
Fix #73793
That's with the best situation, where there's no existing temp files. When the temp folder is nearly full, the existing API deteriorates substantially:
This API will be hidden as part of #72881, but a great deal of code has been written to use it and that code will become faster/more robust. Incidentally, in testing this I filled up the temp folder and (with the previous implementation) Benchmark .NET crashed. That will now be fixed.