Skip to content

Commit 10de2f5

Browse files
committed
Fix concurrent access to dictionary
1 parent 6ae4e9a commit 10de2f5

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/Elastic.Markdown/HtmlWriter.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,12 @@ public async Task<MarkdownDocument> WriteAsync(IDirectoryInfo outBaseDir, IFileI
186186
collector?.Collect(markdown, document, rendered.Html);
187187
await writeFileSystem.File.WriteAllTextAsync(path, rendered.Html, ctx);
188188

189-
if (DocumentationSet.Configuration.Features.LazyLoadNavigation)
190-
{
191-
var navFilePath = Path.Combine(outBaseDir.FullName, rendered.NavigationFileName);
192-
if (!writeFileSystem.File.Exists(navFilePath))
193-
{
194-
await writeFileSystem.File.WriteAllTextAsync(navFilePath, rendered.FullNavigationPartialHtml, ctx);
195-
}
196-
}
189+
if (!DocumentationSet.Configuration.Features.LazyLoadNavigation)
190+
return document;
191+
192+
var navFilePath = Path.Combine(outBaseDir.FullName, rendered.NavigationFileName);
193+
if (!writeFileSystem.File.Exists(navFilePath))
194+
await writeFileSystem.File.WriteAllTextAsync(navFilePath, rendered.FullNavigationPartialHtml, ctx);
197195
return document;
198196
}
199197

src/Elastic.Markdown/IO/DocumentationSet.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5+
using System.Collections.Concurrent;
56
using System.Collections.Frozen;
67
using System.IO.Abstractions;
78
using System.Runtime.InteropServices;
@@ -129,7 +130,7 @@ public class DocumentationSet : INavigationLookups, IPositionalNavigation
129130

130131
public IReadOnlyCollection<IDocsBuilderExtension> EnabledExtensions { get; }
131132

132-
public Dictionary<string, INavigationRenderResult> NavigationRenderResults { get; } = [];
133+
public ConcurrentDictionary<string, INavigationRenderResult> NavigationRenderResults { get; } = [];
133134

134135
public DocumentationSet(
135136
BuildContext context,

0 commit comments

Comments
 (0)