From 4f1064e412d07c4206cb2f135c61d4302cb84d6f Mon Sep 17 00:00:00 2001 From: Senn Geerts Date: Sat, 13 Jul 2024 21:33:08 +0200 Subject: [PATCH] #196 GetStreamFor try recreate directory?? --- .../ToFile/StreamProvider.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AsyncAPI.Saunter.Generator.Cli/ToFile/StreamProvider.cs b/src/AsyncAPI.Saunter.Generator.Cli/ToFile/StreamProvider.cs index 2e28543..19583e6 100644 --- a/src/AsyncAPI.Saunter.Generator.Cli/ToFile/StreamProvider.cs +++ b/src/AsyncAPI.Saunter.Generator.Cli/ToFile/StreamProvider.cs @@ -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();