Skip to content

Commit

Permalink
asyncapi#196 GetStreamFor try recreate directory??
Browse files Browse the repository at this point in the history
  • Loading branch information
Senn Geerts authored and Senn Geerts committed Jul 13, 2024
1 parent fc7cccd commit 4f1064e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/AsyncAPI.Saunter.Generator.Cli/ToFile/StreamProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ public Stream GetStreamFor(string path)

if (!string.IsNullOrEmpty(path))
{
var directory = Path.GetDirectoryName(path);
var directory = new DirectoryInfo(Path.GetDirectoryName(path));
var sw = Stopwatch.StartNew();
do
{
try
{
Directory.CreateDirectory(directory);
directory.Create();
}
catch (Exception e) when (sw.Elapsed < TimeSpan.FromMilliseconds(250))
{
logger.LogDebug(e, "Retry...");
logger.LogDebug(e, $"Retry... {directory.Parent.Exists}, {directory.Parent.Parent.Exists}, {directory.Parent.Parent.Parent.Exists}");
Thread.Sleep(100);
}
}
while (!Directory.Exists(directory));
while (!directory.Exists);
}

return path != null ? File.Create(path) : Console.OpenStandardOutput();
Expand Down

0 comments on commit 4f1064e

Please sign in to comment.