From 6e7a3703f8079ba550ac804ef0458e8402129263 Mon Sep 17 00:00:00 2001 From: Sean McCullough <44180881+seanmcc-msft@users.noreply.github.com> Date: Tue, 29 Jun 2021 20:04:03 -0500 Subject: [PATCH] Fixed bug where BlobBaseClient.DownloadStreamingAsync() won't correctly parse the LeaseStatus header. (#22306) --- sdk/storage/Azure.Storage.Blobs/CHANGELOG.md | 1 + sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs | 1 + sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md b/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md index 977231664daf1..da7230fa67e73 100644 --- a/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md +++ b/sdk/storage/Azure.Storage.Blobs/CHANGELOG.md @@ -12,6 +12,7 @@ - Added optimization to unwrap encryption key once for DownloadTo and OpenRead when Client Side Encryption is enabled. - Added support for RequestConditions parameter validation. If a request condition is set for an API that doesn't support it, and ArguementException will be thrown. - This feature can be disabled with the environment variable "AZURE_STORAGE_DISABLE_REQUEST_CONDITIONS_VALIDATION" or the App Context switch "Azure.Storage.DisableRequestConditionsValidation". +- Fixed bug where BlobBaseClient.DownloadStreamingAsync() won't correctly parse the LeaseStatus header. ## 12.9.1 (2021-06-23) - Added optimization to unwrap encryption key once for DownloadTo and OpenRead when Client Side Encryption is enabled. diff --git a/sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs b/sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs index 13b2b6d98d894..84ce94b5db682 100644 --- a/sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs +++ b/sdk/storage/Azure.Storage.Blobs/src/BlobExtensions.cs @@ -870,6 +870,7 @@ internal static BlobDownloadStreamingResult ToBlobDownloadStreamingResult(this R CopySource = response.Headers.CopySource == null ? null : new Uri(response.Headers.CopySource), CopyStatus = response.Headers.CopyStatus.GetValueOrDefault(), LeaseDuration = response.Headers.LeaseDuration ?? LeaseDurationType.Infinite, + LeaseStatus = response.Headers.LeaseStatus ?? LeaseStatus.Unlocked, LeaseState = response.Headers.LeaseState.GetValueOrDefault(), AcceptRanges = response.Headers.AcceptRanges, BlobCommittedBlockCount = response.Headers.BlobCommittedBlockCount.GetValueOrDefault(), diff --git a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs index 12f9abe479112..8e161f9b47dc6 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/BlobBaseClientTests.cs @@ -304,6 +304,10 @@ public async Task DownloadAsync_Streaming() var actual = new MemoryStream(); await response.Value.Content.CopyToAsync(actual); TestHelper.AssertSequenceEqual(data, actual.ToArray()); + + Assert.AreEqual(LeaseStatus.Unlocked, response.Value.Details.LeaseStatus); + Assert.AreEqual(LeaseState.Available, response.Value.Details.LeaseState); + Assert.AreEqual(LeaseDurationType.Infinite, response.Value.Details.LeaseDuration); } [RecordedTest]