Skip to content

Commit 531b6b2

Browse files
authored
[Storage]Fix sync copy small blob fail #15548 (#15557)
1 parent 862d3c4 commit 531b6b2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
- `Get-AzStorageBlobQueryResult`
2828
* Made `Get-AzDataLakeGen2ChildItem` list all datalake gen2 items by default, instead of needing user to list chunk by chunk.
2929
* Fixed BlobProperties is empty issue when using sas without prefix '?' [#15460]
30+
* Fixed synchronously copy small blob failure [#15548]
31+
- `Copy-AzStorageBlob`
3032

3133
## Version 3.9.0
3234
* Supported enable/disable Blob container soft delete

src/Storage/Storage/Blob/StorageDataMovementCmdletBase.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public class StorageDataMovementCmdletBase : StorageCloudBlobCmdletBase, IDispos
2727
{
2828
protected const int size4MB = 4 * 1024 * 1024;
2929

30+
protected const int size8MB = 8 * 1024 * 1024;
31+
3032
/// <summary>
3133
/// block blob type
3234
/// </summary>
@@ -178,12 +180,16 @@ protected virtual void DoEndProcessing()
178180
/// </summary>
179181
public static long GetBlockLength(long contentLength)
180182
{
183+
if (contentLength <= size8MB)
184+
{
185+
return contentLength;
186+
}
181187
long blockLength = contentLength / 50000;
182-
if (blockLength % (8 * 1024 * 1024) != 0)
188+
if (blockLength % (size8MB) != 0)
183189
{
184-
blockLength = (blockLength / (8 * 1024 * 1024) + 1) * (8 * 1024 * 1024);
190+
blockLength = (blockLength / (size8MB) + 1) * (size8MB);
185191
}
186-
return blockLength;
192+
return blockLength > 0 ? blockLength : contentLength;
187193
}
188194

189195
/// <summary>

0 commit comments

Comments
 (0)