Skip to content

Commit

Permalink
Pleasing Copilot
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros committed Feb 15, 2025
1 parent 37173fa commit 8ec1d1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public static IResourceBuilder<AzureServiceBusResource> RunAsEmulator(this IReso
jsonObject.WriteTo(writer);
}

var aspireStore = builder.ApplicationBuilder.CreateStore();
var aspireStore = AspireStoreExtensions.CreateStore(builder.ApplicationBuilder);

// Deterministic file path for the configuration file based on its content
var configJsonPath = aspireStore.GetFileNameWithContent($"{builder.Resource.Name}-Config.json", tempConfigFile);
Expand Down
19 changes: 12 additions & 7 deletions src/Aspire.Hosting/ApplicationModel/AspireStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,20 @@ public string GetFileNameWithContent(string filenameTemplate, Stream contentStre
{
var buffer = ArrayPool<byte>.Shared.Rent(4096);

int bytesRead;
while ((bytesRead = contentStream.Read(buffer, 0, buffer.Length)) > 0)
try
{
var span = buffer.AsSpan(0, bytesRead);
fileStream.Write(span);
hash.Append(span);
int bytesRead;
while ((bytesRead = contentStream.Read(buffer, 0, buffer.Length)) > 0)
{
var span = buffer.AsSpan(0, bytesRead);
fileStream.Write(span);
hash.Append(span);
}
}
finally
{
ArrayPool<byte>.Shared.Return(buffer);
}

ArrayPool<byte>.Shared.Return(buffer);
}

var name = Path.GetFileNameWithoutExtension(filenameTemplate);
Expand Down

0 comments on commit 8ec1d1d

Please sign in to comment.