fix: shorten GetPipeName() output - #2585
Conversation
|
Like @JC-Chung suggested, reduced the hash length to 8 characters. |
That problem can be totally eliminated if include the user name in hash. What the point to keep it readable in this internal name? |
Something like this? private static string GetPipeName()
{
var dataDir = Native.OS.DataDir.Replace('\\', '/').TrimEnd('/');
var hash = SHA256.HashData(Encoding.UTF8.GetBytes($"{Environment.UserName}_{dataDir}"));
var hashStr = Convert.ToHexString(hash)[..16];
return $"SourceGit_{hashStr}";
} |
Looks like a good solution to me! Want me to update mine to match this, or maybe you can put it as a suggestion through a review and then I can update it like that? |
Redo of #2579 with correct target branch.
This is a hotfix to combat the hard crash on unix machines which was introduced by e0e2ab6
On Unix machines the NamedPipeServerStream is created with a
Path.GetTempPath()and "CoreFXPipe_" prefix, causing the recent change to go over the maximum length of the pipename of 104 characters: dotnet Unix PipeStream sourcecode.Note
In the case of a long username this can still break as we now add an extra 16 characters from the hash to this pipe name.
Closes #2576