@@ -24,6 +24,7 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet
24
24
using Microsoft . WindowsAzure . Commands . Storage . Common ;
25
25
using Microsoft . WindowsAzure . Commands . Storage . Model . Contract ;
26
26
using System ;
27
+ using System . Collections . Generic ;
27
28
using System . Management . Automation ;
28
29
using System . Security . Permissions ;
29
30
using System . Threading . Tasks ;
@@ -380,6 +381,29 @@ private async Task CopyFromUri(long taskId, IStorageBlobManagement destChannel,
380
381
BlobBaseClient srcBlobClient = new BlobBaseClient ( srcUri , ClientOptions ) ;
381
382
Track2Models . BlobProperties srcProperties = srcBlobClient . GetProperties ( cancellationToken : this . CmdletCancellationToken ) . Value ;
382
383
384
+ Track2Models . BlobHttpHeaders httpHeaders = new Track2Models . BlobHttpHeaders
385
+ {
386
+ ContentType = srcProperties . ContentType ,
387
+ ContentLanguage = srcProperties . ContentLanguage ,
388
+ ContentHash = srcProperties . ContentHash ,
389
+ ContentDisposition = srcProperties . ContentDisposition ,
390
+ ContentEncoding = srcProperties . ContentEncoding
391
+ } ;
392
+
393
+ IDictionary < string , string > blobTags = null ;
394
+
395
+ try
396
+ {
397
+ blobTags = srcBlobClient . GetTags ( cancellationToken : this . CmdletCancellationToken ) . Value . Tags ;
398
+ }
399
+ catch ( global ::Azure . RequestFailedException )
400
+ {
401
+ if ( ! this . Force && ! OutputStream . ConfirmAsync ( "Can't get source blob Tags, so source blob tags won't be copied to dest blob. Do you want to continue the blob copy?" ) . Result )
402
+ {
403
+ return ;
404
+ }
405
+ }
406
+
383
407
//Prepare progress handler
384
408
string activity = String . Format ( "Copy Blob {0} to {1}" , srcBlobClient . Name , destBlob . Name ) ;
385
409
string status = "Prepare to Copy Blob" ;
@@ -401,28 +425,21 @@ private async Task CopyFromUri(long taskId, IStorageBlobManagement destChannel,
401
425
PageBlobClient destPageBlob = ( PageBlobClient ) Util . GetTrack2BlobClientWithType ( destBlob , destChannel . StorageContext , Track2Models . BlobType . Page , ClientOptions ) ;
402
426
403
427
Track2Models . PageBlobCreateOptions pageBlobCreateOptions = new Track2Models . PageBlobCreateOptions ( ) ;
404
- Track2Models . BlobHttpHeaders httpHeaders = new Track2Models . BlobHttpHeaders
405
- {
406
- ContentType = srcProperties . ContentType ,
407
- ContentLanguage = srcProperties . ContentLanguage ,
408
- ContentHash = srcProperties . ContentHash ,
409
- ContentDisposition = srcProperties . ContentDisposition ,
410
- ContentEncoding = srcProperties . ContentEncoding
411
- } ;
412
428
pageBlobCreateOptions . HttpHeaders = httpHeaders ;
413
429
pageBlobCreateOptions . Metadata = srcProperties . Metadata ;
414
-
415
- try
416
- {
417
- pageBlobCreateOptions . Tags = srcBlobClient . GetTags ( cancellationToken : this . CmdletCancellationToken ) . Value . Tags ;
418
- }
419
- catch ( global ::Azure . RequestFailedException )
420
- {
421
- if ( ! this . Force && ! OutputStream . ConfirmAsync ( "Can't get source blob Tags, so source blob tags won't be copied to dest blob. Do you want to continue the blob copy?" ) . Result )
422
- {
423
- return ;
424
- }
425
- }
430
+ pageBlobCreateOptions . Tags = blobTags ?? null ;
431
+
432
+ //try
433
+ //{
434
+ // pageBlobCreateOptions.Tags = srcBlobClient.GetTags(cancellationToken: this.CmdletCancellationToken).Value.Tags;
435
+ //}
436
+ //catch (global::Azure.RequestFailedException)
437
+ //{
438
+ // if (!this.Force && !OutputStream.ConfirmAsync("Can't get source blob Tags, so source blob tags won't be copied to dest blob. Do you want to continue the blob copy?").Result)
439
+ // {
440
+ // return;
441
+ // }
442
+ //}
426
443
427
444
destPageBlob . Create ( srcProperties . ContentLength , pageBlobCreateOptions , this . CmdletCancellationToken ) ;
428
445
@@ -444,28 +461,21 @@ private async Task CopyFromUri(long taskId, IStorageBlobManagement destChannel,
444
461
AppendBlobClient destAppendBlob = ( AppendBlobClient ) Util . GetTrack2BlobClientWithType ( destBlob , destChannel . StorageContext , Track2Models . BlobType . Append , ClientOptions ) ;
445
462
446
463
Track2Models . AppendBlobCreateOptions appendBlobCreateOptions = new Track2Models . AppendBlobCreateOptions ( ) ;
447
- Track2Models . BlobHttpHeaders appendBlobHttpHeaders = new Track2Models . BlobHttpHeaders
448
- {
449
- ContentType = srcProperties . ContentType ,
450
- ContentLanguage = srcProperties . ContentLanguage ,
451
- ContentEncoding = srcProperties . ContentEncoding ,
452
- ContentDisposition = srcProperties . ContentDisposition ,
453
- ContentHash = srcProperties . ContentHash
454
- } ;
455
- appendBlobCreateOptions . HttpHeaders = appendBlobHttpHeaders ;
464
+ appendBlobCreateOptions . HttpHeaders = httpHeaders ;
456
465
appendBlobCreateOptions . Metadata = srcProperties . Metadata ;
457
-
458
- try
459
- {
460
- appendBlobCreateOptions . Tags = srcBlobClient . GetTags ( cancellationToken : this . CmdletCancellationToken ) . Value . Tags ;
461
- }
462
- catch ( global ::Azure . RequestFailedException )
463
- {
464
- if ( ! this . Force && ! OutputStream . ConfirmAsync ( "Can't get source blob Tags, so source blob tags won't be copied to dest blob. Do you want to continue the blob copy?" ) . Result )
465
- {
466
- return ;
467
- }
468
- }
466
+ appendBlobCreateOptions . Tags = blobTags ?? null ;
467
+
468
+ //try
469
+ //{
470
+ // appendBlobCreateOptions.Tags = srcBlobClient.GetTags(cancellationToken: this.CmdletCancellationToken).Value.Tags;
471
+ //}
472
+ //catch (global::Azure.RequestFailedException)
473
+ //{
474
+ // if (!this.Force && !OutputStream.ConfirmAsync("Can't get source blob Tags, so source blob tags won't be copied to dest blob. Do you want to continue the blob copy?").Result)
475
+ // {
476
+ // return;
477
+ // }
478
+ //}
469
479
470
480
destAppendBlob . Create ( appendBlobCreateOptions , this . CmdletCancellationToken ) ;
471
481
@@ -504,18 +514,19 @@ private async Task CopyFromUri(long taskId, IStorageBlobManagement destChannel,
504
514
}
505
515
options . SourceConditions = this . BlobRequestConditions ;
506
516
options . Metadata = srcProperties . Metadata ;
507
-
508
- try
509
- {
510
- options . Tags = srcBlobClient . GetTags ( cancellationToken : this . CmdletCancellationToken ) . Value . Tags ;
511
- }
512
- catch ( global ::Azure . RequestFailedException )
513
- {
514
- if ( ! this . Force && ! OutputStream . ConfirmAsync ( "Can't get source blob Tags, so source blob tags won't be copied to dest blob. Do you want to continue the blob copy?" ) . Result )
515
- {
516
- return ;
517
- }
518
- }
517
+ options . Tags = blobTags ?? null ;
518
+
519
+ //try
520
+ //{
521
+ // options.Tags = srcBlobClient.GetTags(cancellationToken: this.CmdletCancellationToken).Value.Tags;
522
+ //}
523
+ //catch (global::Azure.RequestFailedException)
524
+ //{
525
+ // if (!this.Force && !OutputStream.ConfirmAsync("Can't get source blob Tags, so source blob tags won't be copied to dest blob. Do you want to continue the blob copy?").Result)
526
+ // {
527
+ // return;
528
+ // }
529
+ //}
519
530
destBlobClient . SyncCopyFromUri ( srcUri , options , this . CmdletCancellationToken ) ;
520
531
521
532
// Set rehydrate priority
@@ -530,29 +541,26 @@ private async Task CopyFromUri(long taskId, IStorageBlobManagement destChannel,
530
541
BlockBlobClient destBlockBlob = ( BlockBlobClient ) Util . GetTrack2BlobClientWithType ( destBlob , destChannel . StorageContext , Track2Models . BlobType . Block , ClientOptions ) ;
531
542
532
543
Track2Models . CommitBlockListOptions commitBlockListOptions = new Track2Models . CommitBlockListOptions ( ) ;
533
- commitBlockListOptions . HttpHeaders = new Track2Models . BlobHttpHeaders ( ) ;
534
- commitBlockListOptions . HttpHeaders . ContentType = srcProperties . ContentType ;
535
- commitBlockListOptions . HttpHeaders . ContentHash = srcProperties . ContentHash ;
536
- commitBlockListOptions . HttpHeaders . ContentEncoding = srcProperties . ContentEncoding ;
537
- commitBlockListOptions . HttpHeaders . ContentLanguage = srcProperties . ContentLanguage ;
538
- commitBlockListOptions . HttpHeaders . ContentDisposition = srcProperties . ContentDisposition ;
544
+ commitBlockListOptions . HttpHeaders = httpHeaders ;
539
545
commitBlockListOptions . Metadata = srcProperties . Metadata ;
546
+ commitBlockListOptions . Tags = blobTags ?? null ;
547
+
540
548
if ( standardBlobTier != null )
541
549
{
542
550
commitBlockListOptions . AccessTier = Util . ConvertAccessTier_Track1ToTrack2 ( standardBlobTier ) ;
543
551
}
544
552
545
- try
546
- {
547
- commitBlockListOptions . Tags = srcBlobClient . GetTags ( cancellationToken : this . CmdletCancellationToken ) . Value . Tags ;
548
- }
549
- catch ( global ::Azure . RequestFailedException )
550
- {
551
- if ( ! this . Force && ! OutputStream . ConfirmAsync ( "Can't get source blob Tags, so source blob tags won't be copied to dest blob. Do you want to continue the blob copy?" ) . Result )
552
- {
553
- return ;
554
- }
555
- }
553
+ // try
554
+ // {
555
+ // commitBlockListOptions.Tags = srcBlobClient.GetTags(cancellationToken: this.CmdletCancellationToken).Value.Tags;
556
+ // }
557
+ // catch (global::Azure.RequestFailedException)
558
+ // {
559
+ // if (!this.Force && !OutputStream.ConfirmAsync("Can't get source blob Tags, so source blob tags won't be copied to dest blob. Do you want to continue the blob copy?").Result)
560
+ // {
561
+ // return;
562
+ // }
563
+ // }
556
564
557
565
long blockLength = GetBlockLength ( srcProperties . ContentLength ) ;
558
566
string [ ] blockIDs = GetBlockIDs ( srcProperties . ContentLength , blockLength , destBlockBlob . Name ) ;
0 commit comments