Skip to content

[Storage]Fix sync copy small blob fail #15548 #15557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Storage/Storage.Management/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- `Add-AzStorageAccountManagementPolicyAction`
* Made `Get-AzDataLakeGen2ChildItem` list all datalake gen2 items by default, instead of needing user to list chunk by chunk.
* Fixed BlobProperties is empty issue when using sas without prefix '?' [#15460]
* Fixed synchronously copy small blob failure [#15548]
- `Copy-AzStorageBlob`

## Version 3.9.0
* Supported enable/disable Blob container soft delete
Expand Down
12 changes: 9 additions & 3 deletions src/Storage/Storage/Blob/StorageDataMovementCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class StorageDataMovementCmdletBase : StorageCloudBlobCmdletBase, IDispos
{
protected const int size4MB = 4 * 1024 * 1024;

protected const int size8MB = 8 * 1024 * 1024;

/// <summary>
/// block blob type
/// </summary>
Expand Down Expand Up @@ -178,12 +180,16 @@ protected virtual void DoEndProcessing()
/// </summary>
public static long GetBlockLength(long contentLength)
{
if (contentLength <= size8MB)
{
return contentLength;
}
long blockLength = contentLength / 50000;
if (blockLength % (8 * 1024 * 1024) != 0)
if (blockLength % (size8MB) != 0)
{
blockLength = (blockLength / (8 * 1024 * 1024) + 1) * (8 * 1024 * 1024);
blockLength = (blockLength / (size8MB) + 1) * (size8MB);
}
return blockLength;
return blockLength > 0 ? blockLength : contentLength;
}

/// <summary>
Expand Down