diff --git a/ChangeLog.md b/ChangeLog.md index d37475c4..3406f9f9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,11 @@ > See [BreakingChanges](BreakingChanges.md) for a detailed list of API breaks. +## Version 0.34.1: + +### Blob: +- Fixed a bug where downloading the snapshot of a blob will fail in some cases. + ## Version 0.34.0: ### All: diff --git a/azure/storage/blob/_download_chunking.py b/azure/storage/blob/_download_chunking.py index 597863aa..1c2d4f92 100644 --- a/azure/storage/blob/_download_chunking.py +++ b/azure/storage/blob/_download_chunking.py @@ -20,7 +20,7 @@ ) from .._error import _ERROR_NO_SINGLE_THREAD_CHUNKING -def _download_blob_chunks(blob_service, container_name, blob_name, +def _download_blob_chunks(blob_service, container_name, blob_name, snapshot, download_size, block_size, progress, start_range, end_range, stream, max_connections, progress_callback, validate_content, lease_id, if_modified_since, if_unmodified_since, if_match, @@ -32,6 +32,7 @@ def _download_blob_chunks(blob_service, container_name, blob_name, blob_service, container_name, blob_name, + snapshot, download_size, block_size, progress, @@ -54,13 +55,14 @@ def _download_blob_chunks(blob_service, container_name, blob_name, result = list(executor.map(downloader.process_chunk, downloader.get_chunk_offsets())) class _BlobChunkDownloader(object): - def __init__(self, blob_service, container_name, blob_name, download_size, + def __init__(self, blob_service, container_name, blob_name, snapshot, download_size, chunk_size, progress, start_range, end_range, stream, progress_callback, validate_content, lease_id, if_modified_since, if_unmodified_since, if_match, if_none_match, timeout, operation_context): self.blob_service = blob_service self.container_name = container_name self.blob_name = blob_name + self.snapshot = snapshot self.chunk_size = chunk_size self.download_size = download_size @@ -117,6 +119,7 @@ def _download_chunk(self, chunk_start, chunk_end): response = self.blob_service._get_blob( self.container_name, self.blob_name, + snapshot=self.snapshot, start_range=chunk_start, end_range=chunk_end - 1, validate_content=self.validate_content, diff --git a/azure/storage/blob/baseblobservice.py b/azure/storage/blob/baseblobservice.py index 4fc994b3..e344e75b 100644 --- a/azure/storage/blob/baseblobservice.py +++ b/azure/storage/blob/baseblobservice.py @@ -1985,6 +1985,7 @@ def get_blob_to_stream( self, container_name, blob_name, + snapshot, download_size, self.MAX_CHUNK_GET_SIZE, first_get_size, diff --git a/tests/test_get_blob.py b/tests/test_get_blob.py index a24c7ecb..4ddaca35 100644 --- a/tests/test_get_blob.py +++ b/tests/test_get_blob.py @@ -147,6 +147,21 @@ def test_get_blob_to_bytes(self): # Assert self.assertEqual(self.byte_data, blob.content) + def test_get_blob_to_bytes_snapshot(self): + # parallel tests introduce random order of requests, can only run live + if TestMode.need_recording_file(self.test_mode): + return + + # Arrange + snapshot = self.bs.snapshot_blob(self.container_name, self.byte_blob) + self.bs.create_blob_from_bytes(self.container_name, self.byte_blob, self.byte_data) # Modify the blob so the Etag no longer matches + + # Act + blob = self.bs.get_blob_to_bytes(self.container_name, self.byte_blob, snapshot.snapshot) + + # Assert + self.assertEqual(self.byte_data, blob.content) + def test_get_blob_to_bytes_with_progress(self): # parallel tests introduce random order of requests, can only run live if TestMode.need_recording_file(self.test_mode):