Skip to content

Commit

Permalink
- disables caching for localhost descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet committed Sep 18, 2023
1 parent 8225a22 commit de439a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Localhost based descriptions are not cached anymore to facilitate development workflows. [#3316](https://github.com/microsoft/kiota/issues/3316)

## [1.6.1] - 2023-09-11

### Changed
Expand Down
13 changes: 9 additions & 4 deletions src/Kiota.Builder/Caching/DocumentCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,17 @@ private async Task<Stream> DownloadDocumentFromSourceAsync(Uri documentUri, stri
responseMessage.EnsureSuccessStatusCode();
content = new MemoryStream();
await responseMessage.Content.CopyToAsync(content, token).ConfigureAwait(false);
if (documentUri.IsLoopback)
Logger.LogInformation("skipping cache write for URI {Uri} as it is a loopback address", documentUri);
else
{
#pragma warning disable CA2007
await using var fileStream = File.Create(target);
await using var fileStream = File.Create(target);
#pragma warning restore CA2007
content.Position = 0;
await content.CopyToAsync(fileStream, token).ConfigureAwait(false);
await fileStream.FlushAsync(token).ConfigureAwait(false);
content.Position = 0;
await content.CopyToAsync(fileStream, token).ConfigureAwait(false);
await fileStream.FlushAsync(token).ConfigureAwait(false);
}
content.Position = 0;
return content;
}
Expand Down

0 comments on commit de439a3

Please sign in to comment.