Check HTTP status code before writing response to file (#8863)

fix https://github.com/jellyfin/jellyfin/issues/8084
This commit is contained in:
Bond-009 2022-12-07 18:14:32 +01:00 committed by GitHub
parent 8258d884f3
commit 16fdb127ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -149,11 +149,11 @@ namespace MediaBrowser.Providers.Plugins.AudioDb
var url = BaseUrl + "/artist-mb.php?i=" + musicBrainzId;
var path = GetArtistInfoPath(_config.ApplicationPaths, musicBrainzId);
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
var path = GetArtistInfoPath(_config.ApplicationPaths, musicBrainzId);
Directory.CreateDirectory(Path.GetDirectoryName(path));
var fileStreamOptions = AsyncFile.WriteOptions;