-
Notifications
You must be signed in to change notification settings - Fork 1.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
Use GetRandomFileName when creating random temp folder to avoid conflict #5229
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9c0a70c
add random seed when create random temp folder to avoid conflict
frank-dong-ms e1a7272
use guid hash instead of system time to generate random number
frank-dong-ms 5177ac6
take comments
frank-dong-ms dc9b828
code clean up
frank-dong-ms 8f58ec8
fix bug
frank-dong-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
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.
Is there an associated bug? Are we seeing an issue here?
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.
yes, this PR is to fix below issue:
#5210
In reply to: 438920139 [](ancestors = 438920139)
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.
❔ Why not just use
Path.GetRandomFileName()
?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.
The entire implementation of
GetShortTempDir()
can be reduced to this:The ml_tests subdirectory allows a user to easily identify and delete stray folders created by tests. You definitely don't want to place the folders directly in
%TEMP%
which is what happens today.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.
Yes, please use
Path.GetRandomFileName()
. The original code hadRandomUtils.Create
, but we have seen it cause conflicts when it comes to file names. We have started replacing those withPath.GetRandomFileName()
In reply to: 438940202 [](ancestors = 438940202)
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.
No, I don't have repro, user who reported this issue also don't have repro on his local env, he get error from their product environment but not able to provide a repro
In reply to: 438942892 [](ancestors = 438942892,438936814,438920139)
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.
I see that
Path.GetRandomFileName()
is indeed superior at generating file and/or directory names, so I'm in favor of using this too. It does seem to be limited to generating just 11 characters, though this will probably be more than enough.It also seems interesting that here
Path.GetTempPath()
has been added, butPath.GetRandomFileName()
wasn't. I wonder if there's a reason why
Path.GetRandomFileName()` wasn't used in the first place.Thanks @sharwell and @harishsk for the heads up.
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.
Thanks, that make sense
In reply to: 438942324 [](ancestors = 438942324,438940202)
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.
Yeah, that is great idea, one little modification is I want to change "ml_tests" to "ml_dotnet" as this is not for test usage.
In reply to: 438941863 [](ancestors = 438941863)
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.
checked the implementation again, Path.GetRandomFileName() is already added at line 239 by Jon Wood at 1/31/2020 at below PR:
#4645
so consider this PR as code cleanup
In reply to: 438971881 [](ancestors = 438971881,438941863)