Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Microsoft.ML.Core/Data/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ private static string GetShortTempDir(IExceptionContext ectx)
string tempPath = ectx is IHostEnvironmentInternal iHostInternal ?
iHostInternal.TempFilePath :
Path.GetTempPath();
int dirNumber = 0;
string mlNetTempDir = null!;
while (Directory.Exists(mlNetTempDir = Path.Combine(Path.GetFullPath(tempPath), $"ml_dotnet{dirNumber++}"))) ;
var path = Path.Combine(mlNetTempDir, Path.GetRandomFileName());

// Find a unique directory, the directory under Temp and must be unique to this process
string path = null;
while (path is null || Directory.Exists(path))
{
path = Path.Combine(Path.GetFullPath(tempPath), $"ml_dotnet_{Path.GetRandomFileName()}");
}

Directory.CreateDirectory(path);
return path;
}
Expand Down
Loading