Skip to content

Commit c4b554f

Browse files
committed
Should return more meaningful error message when the input blob type is different with the actual blob type.
1 parent 957b831 commit c4b554f

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/Common/Storage/Commands.Storage/Blob/Cmdlet/StartAzureStorageBlobCopy.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet
3636
OutputType(typeof(AzureStorageBlob))]
3737
public class StartAzureStorageBlobCopy : StorageDataMovementCmdletBase, IModuleAssemblyInitializer
3838
{
39+
private const string BlobTypeMismatch = "Blob type of the blob reference doesn't match blob type of the blob.";
40+
3941
/// <summary>
4042
/// Blob Pipeline parameter set name
4143
/// </summary>
@@ -472,7 +474,20 @@ private void StartCopyFromFile(IStorageBlobManagement destChannel, CloudFile src
472474

473475
private async Task StartCopyFromBlob(long taskId, IStorageBlobManagement destChannel, CloudBlob srcBlob, CloudBlob destBlob)
474476
{
475-
await StartCopyFromUri(taskId, destChannel, srcBlob.GenerateUriWithCredentials(), destBlob);
477+
try
478+
{
479+
await StartCopyFromUri(taskId, destChannel, srcBlob.GenerateUriWithCredentials(), destBlob);
480+
}
481+
catch (StorageException ex)
482+
{
483+
if (0 == string.Compare(ex.Message, BlobTypeMismatch, StringComparison.OrdinalIgnoreCase))
484+
{
485+
// Current use error message to decide whether it caused by blob type mismatch,
486+
// We should ask xscl to expose an error code for this..
487+
// Opened workitem 1487579 to track this.
488+
throw new InvalidOperationException(Resources.DestinationBlobTypeNotMatch);
489+
}
490+
}
476491
}
477492

478493
private async Task StartCopyFromUri(long taskId, IStorageBlobManagement destChannel, Uri srcUri, CloudBlob destBlob)

src/Common/Storage/Commands.Storage/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Common/Storage/Commands.Storage/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,9 @@
519519
<value>CopyId mismatch on blob '{0}' in container '{1}'. Expected:{2}. User supplied: {3}.</value>
520520
<comment>0 for blob name, 1 for container name. 2 for copy id on blob, 3 for user supplied copy id.</comment>
521521
</data>
522+
<data name="DestinationBlobTypeNotMatch" xml:space="preserve">
523+
<value>User specified blob type does not match the blob type of the existing destination blob.</value>
524+
</data>
522525
<data name="StopCopyOperationCancelled" xml:space="preserve">
523526
<value>The stop copy operation on blob '{0}' in container '{1}' is cancelled.</value>
524527
<comment>0 for blob name, 1 for container name.</comment>

0 commit comments

Comments
 (0)