Skip to content

Commit

Permalink
[Storage] Fix content range check for empty files (#26872)
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddavis authored Oct 18, 2022
1 parent fc76739 commit 570cabe
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions sdk/storage/azure-storage-blob/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Breaking Changes

### Bugs Fixed
- Fixed possible invalid content range exception that gets raised when downloading empty blobs through Azurite.

### Other Changes
- Removed `msrest` dependency.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def _initial_request(self):
# Parse the total file size and adjust the download size if ranges
# were specified
self._file_size = parse_length_from_content_range(response.properties.content_range)
if not self._file_size:
if self._file_size is None:
raise ValueError("Required Content-Range response header is missing or malformed.")
# Remove any extra encryption data size from blob size
self._file_size = adjust_blob_size_for_encryption(self._file_size, self._encryption_data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ async def _initial_request(self):
# Parse the total file size and adjust the download size if ranges
# were specified
self._file_size = parse_length_from_content_range(response.properties.content_range)
if not self._file_size:
if self._file_size is None:
raise ValueError("Required Content-Range response header is missing or malformed.")
# Remove any extra encryption data size from blob size
self._file_size = adjust_blob_size_for_encryption(self._file_size, self._encryption_data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def _initial_request(self):
# Parse the total file size and adjust the download size if ranges
# were specified
self._file_size = parse_length_from_content_range(response.properties.content_range)
if not self._file_size:
if self._file_size is None:
raise ValueError("Required Content-Range response header is missing or malformed.")

if self._end_range is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ async def _initial_request(self):
# Parse the total file size and adjust the download size if ranges
# were specified
self._file_size = parse_length_from_content_range(response.properties.content_range)
if not self._file_size:
if self._file_size is None:
raise ValueError("Required Content-Range response header is missing or malformed.")

if self._end_range is not None:
Expand Down

0 comments on commit 570cabe

Please sign in to comment.