diff --git a/sdk/storage/Azure.Storage.Blobs/README.md b/sdk/storage/Azure.Storage.Blobs/README.md index 4d7e4c9f68798..2db7c7f8c5803 100644 --- a/sdk/storage/Azure.Storage.Blobs/README.md +++ b/sdk/storage/Azure.Storage.Blobs/README.md @@ -216,7 +216,7 @@ BlobContainerClientTransferOptions options = new BlobContainerClientTransferOpti }, TransferOptions = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, } }; @@ -249,7 +249,7 @@ BlobContainerClientTransferOptions options = new BlobContainerClientTransferOpti }, TransferOptions = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, } }; diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/README.md b/sdk/storage/Azure.Storage.DataMovement.Blobs/README.md index 19adc6f5a2843..cc18b1b797b3f 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/README.md +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/README.md @@ -272,7 +272,7 @@ BlobContainerClientTransferOptions options = new BlobContainerClientTransferOpti }, TransferOptions = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, } }; @@ -305,7 +305,7 @@ BlobContainerClientTransferOptions options = new BlobContainerClientTransferOpti }, TransferOptions = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, } }; diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/perf/Azure.Storage.DataMovement.Blobs.Perf/Infrastructure/DirectoryTransferTest.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/perf/Azure.Storage.DataMovement.Blobs.Perf/Infrastructure/DirectoryTransferTest.cs index 931ea55edd17b..fb7d7d685f3d9 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/perf/Azure.Storage.DataMovement.Blobs.Perf/Infrastructure/DirectoryTransferTest.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/perf/Azure.Storage.DataMovement.Blobs.Perf/Infrastructure/DirectoryTransferTest.cs @@ -29,8 +29,8 @@ public DirectoryTransferTest(TOptions options) : base(options) TransferManagerOptions managerOptions = new() { - ErrorHandling = TransferErrorMode.StopOnAnyFailure, - CheckpointerOptions = Options.DisableCheckpointer ? TransferCheckpointStoreOptions.Disabled() : default, + ErrorMode = TransferErrorMode.StopOnAnyFailure, + CheckpointStoreOptions = Options.DisableCheckpointer ? TransferCheckpointStoreOptions.DisableCheckpoint() : default, MaximumConcurrency = Options.Concurrency }; _transferManager = new TransferManager(managerOptions); @@ -85,7 +85,7 @@ protected async Task RunAndVerifyTransferAsync( { TransferOptions options = new() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, InitialTransferSize = Options.InitialTransferSize, MaximumTransferChunkSize = Options.ChunkSize, }; diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/samples/Sample01b_HelloWorldAsync.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/samples/Sample01b_HelloWorldAsync.cs index 06782fe653236..c8e683d63db5d 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/samples/Sample01b_HelloWorldAsync.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/samples/Sample01b_HelloWorldAsync.cs @@ -271,7 +271,7 @@ public async Task DownloadSingle_SharedKeyAuthAsync() // Create Blob Data Controller to skip through all failures TransferManagerOptions options = new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; TransferManager transferManager = new TransferManager(options); BlobsStorageResourceProvider blobs = new(); @@ -368,7 +368,7 @@ public async Task UploadDirectory_SasAsync() TransferOptions options = new TransferOptions() { MaximumTransferChunkSize = 4 * Constants.MB, - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, }; TransferManager transferManager = new TransferManager(transferManagerOptions); @@ -463,7 +463,7 @@ public async Task UploadDirectory_CompletedEventHandler() { using (StreamWriter logStream = File.AppendText(logFile)) { - logStream.WriteLine($"File Completed Transfer: {args.SourceResource.Uri.AbsoluteUri}"); + logStream.WriteLine($"File Completed Transfer: {args.Source.Uri.AbsoluteUri}"); } return Task.CompletedTask; }; @@ -565,8 +565,8 @@ public async Task UploadDirectory_EventHandler_SasAsync() // Specifying specific resources that failed, since its a directory transfer // maybe only one file failed out of many logStream.WriteLine($"Exception occurred with TransferId: {args.TransferId}," + - $"Source Resource: {args.SourceResource.Uri.AbsoluteUri}, +" + - $"Destination Resource: {args.DestinationResource.Uri.AbsoluteUri}," + + $"Source Resource: {args.Source.Uri.AbsoluteUri}, +" + + $"Destination Resource: {args.Destination.Uri.AbsoluteUri}," + $"Exception Message: {args.Exception.Message}"); } return Task.CompletedTask; @@ -901,7 +901,7 @@ public async Task PauseAndResumeAsync_ManagerId() // Pause from the Transfer Manager using the Transfer Id #region Snippet:PauseFromManager - await transferManager.PauseTransferIfRunningAsync(transferId); + await transferManager.PauseTransferAsync(transferId); #endregion // Resume all transfers @@ -1029,7 +1029,7 @@ public async Task UploadDirectory() }, TransferOptions = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, } }; @@ -1099,7 +1099,7 @@ public async Task DownloadDirectory() }, TransferOptions = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, } }; @@ -1152,7 +1152,7 @@ async Task ListenToTransfersAsync(TransferManager transferMan transferOptions.ItemTransferCompleted += (TransferItemCompletedEventArgs args) => { using StreamWriter logStream = File.AppendText(logFile); - logStream.WriteLine($"File Completed Transfer: {args.SourceResource.Uri.LocalPath}"); + logStream.WriteLine($"File Completed Transfer: {args.Source.Uri.LocalPath}"); return Task.CompletedTask; }; return await transferManager.StartTransferAsync( diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/DataMovementBlobsExtensions.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/DataMovementBlobsExtensions.cs index e11f9931fcd12..ecd772c2f5309 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/src/DataMovementBlobsExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/src/DataMovementBlobsExtensions.cs @@ -52,11 +52,13 @@ internal static StorageResourceItemProperties ToStorageResourceProperties(this B properties.Add(DataMovementConstants.ResourceProperties.AccessTier, new AccessTier(blobProperties.AccessTier)); } - return new StorageResourceItemProperties( - resourceLength: blobProperties.ContentLength, - eTag: blobProperties.ETag, - lastModifiedTime: blobProperties.LastModified, - properties: properties); + return new StorageResourceItemProperties() + { + ResourceLength = blobProperties.ContentLength, + ETag = blobProperties.ETag, + LastModifiedTime = blobProperties.LastModified, + RawProperties = properties + }; } internal static StorageResourceItemProperties ToStorageResourceItemProperties(this BlobDownloadStreamingResult result) @@ -102,11 +104,13 @@ internal static StorageResourceItemProperties ToStorageResourceItemProperties(th size = contentRange.Size; } - return new StorageResourceItemProperties( - resourceLength: size, - eTag : result?.Details.ETag, - lastModifiedTime: result?.Details.LastModified, - properties: properties); + return new StorageResourceItemProperties() + { + ResourceLength = size, + ETag = result?.Details.ETag, + LastModifiedTime = result?.Details.LastModified, + RawProperties = properties + }; } internal static StorageResourceReadStreamResult ToReadStreamStorageResourceInfo(this BlobDownloadStreamingResult result) @@ -162,11 +166,13 @@ internal static StorageResourceReadStreamResult ToReadStreamStorageResourceInfo( return new StorageResourceReadStreamResult( content: result.Content, range: range, - properties: new StorageResourceItemProperties( - resourceLength: size.HasValue ? size : result.Details.ContentLength, - eTag: result.Details.ETag, - lastModifiedTime: result?.Details.LastModified, - properties: properties)); + properties: new StorageResourceItemProperties() + { + ResourceLength = size.HasValue ? size : result.Details.ContentLength, + ETag = result.Details.ETag, + LastModifiedTime = result?.Details.LastModified, + RawProperties = properties + }); } /// @@ -631,11 +637,13 @@ internal static StorageResourceItemProperties ToResourceProperties(this BlobItem properties.Add(DataMovementConstants.ResourceProperties.CacheControl, blobItem.Properties.CacheControl); } - return new StorageResourceItemProperties( - resourceLength: blobItem.Properties.ContentLength, - eTag: blobItem.Properties.ETag, - lastModifiedTime: blobItem.Properties.LastModified, - properties: properties); + return new StorageResourceItemProperties() + { + ResourceLength = blobItem.Properties.ContentLength, + ETag = blobItem.Properties.ETag, + LastModifiedTime = blobItem.Properties.LastModified, + RawProperties = properties + }; } private static string ConvertContentPropertyObjectToString(string contentPropertyName, object contentPropertyValue) @@ -656,7 +664,7 @@ private static string ConvertContentPropertyObjectToString(string contentPropert private static BlobHttpHeaders GetHttpHeaders( BlobStorageResourceOptions options, - Dictionary properties) + IDictionary properties) => new() { ContentType = (options?.ContentType?.Preserve ?? true) @@ -689,7 +697,7 @@ private static BlobHttpHeaders GetHttpHeaders( // Get the access tier property private static AccessTier? GetAccessTier( BlobStorageResourceOptions options, - Dictionary properties) + IDictionary properties) => options?.AccessTier != default ? options?.AccessTier : properties?.TryGetValue(DataMovementConstants.ResourceProperties.AccessTier, out object accessTierObject) == true @@ -699,7 +707,7 @@ private static BlobHttpHeaders GetHttpHeaders( // By default we preserve the metadata private static Metadata GetMetadata( BlobStorageResourceOptions options, - Dictionary properties) + IDictionary properties) => (options?.Metadata?.Preserve ?? true) ? properties?.TryGetValue(DataMovementConstants.ResourceProperties.Metadata, out object metadataObject) == true ? (Metadata) metadataObject diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/stress/src/Infrastructure/StressEventsRaised.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/stress/src/Infrastructure/StressEventsRaised.cs index e764550d77da7..21a8c9e9ec206 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/stress/src/Infrastructure/StressEventsRaised.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/stress/src/Infrastructure/StressEventsRaised.cs @@ -137,8 +137,8 @@ public void AssertUnexpectedFailureCheck() { Assert.Fail( $"Failure occurred at Transfer id: {failure.TransferId}.\n" + - $"Source Resource Path: {failure.SourceResource.Uri.AbsoluteUri}\n" + - $"Destination Resource Path: {failure.DestinationResource.Uri.AbsoluteUri}\n" + + $"Source Resource Path: {failure.Source.Uri.AbsoluteUri}\n" + + $"Destination Resource Path: {failure.Destination.Uri.AbsoluteUri}\n" + $"Exception Message: {failure.Exception.Message}\n" + $"Exception Stack: {failure.Exception.StackTrace}\n"); } @@ -177,8 +177,8 @@ public async Task AssertSingleSkippedCheck() AssertUnexpectedFailureCheck(); Assert.IsEmpty(SingleCompletedEvents); Assert.AreEqual(1, SkippedEvents.Count); - Assert.NotNull(SkippedEvents.First().SourceResource.Uri); - Assert.NotNull(SkippedEvents.First().DestinationResource.Uri); + Assert.NotNull(SkippedEvents.First().Source.Uri); + Assert.NotNull(SkippedEvents.First().Destination.Uri); AssertTransferStatusCollection( new TransferStatus[] { @@ -202,8 +202,8 @@ public async Task AssertSingleFailedCheck(int failureCount) foreach (TransferItemFailedEventArgs args in FailedEvents) { Assert.NotNull(args.Exception); - Assert.NotNull(args.SourceResource.Uri); - Assert.NotNull(args.DestinationResource.Uri); + Assert.NotNull(args.Source.Uri); + Assert.NotNull(args.Destination.Uri); } AssertTransferStatusCollection( diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/AppendBlobStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/AppendBlobStorageResourceTests.cs index 36eea9f4d7349..1394eeee40053 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/AppendBlobStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/AppendBlobStorageResourceTests.cs @@ -299,11 +299,13 @@ public async Task CopyFromStreamAsync_PropertiesDefault() }; StorageResourceWriteToOffsetOptions copyFromStreamOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromStreamInternalAsync( stream, @@ -400,11 +402,13 @@ public async Task CopyFromStreamAsync_PropertiesPreserve() }; StorageResourceWriteToOffsetOptions copyFromStreamOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromStreamInternalAsync( stream, @@ -501,11 +505,13 @@ public async Task CopyFromStreamAsync_PropertiesNoPreserve() }; StorageResourceWriteToOffsetOptions copyFromStreamOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromStreamInternalAsync( stream, @@ -710,11 +716,13 @@ public async Task CopyFromUriAsync_PropertiesDefault() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromUriInternalAsync( sourceResource.Object, @@ -813,11 +821,13 @@ public async Task CopyFromUriAsync_PropertiesPreserve() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromUriInternalAsync( sourceResource.Object, @@ -917,11 +927,13 @@ public async Task CopyFromUriAsync_PropertiesNoPreserve() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromUriInternalAsync( sourceResource.Object, @@ -1213,11 +1225,13 @@ public async Task CopyBlockFromUriAsync_PropertiesDefault() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyBlockFromUriInternalAsync( sourceResource.Object, @@ -1318,11 +1332,13 @@ public async Task CopyBlockFromUriAsync_PropertiesPreserve() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyBlockFromUriInternalAsync( sourceResource.Object, @@ -1423,11 +1439,13 @@ public async Task CopyBlockFromUriAsync_PropertiesNoPreserve() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyBlockFromUriInternalAsync( sourceResource.Object, @@ -1597,11 +1615,13 @@ public async Task GetPropertiesAsync_Cached() BlockBlobStorageResource storageResource = new BlockBlobStorageResource( mock.Object, - new StorageResourceItemProperties( - length, - eTag, - lastModified, - rawProperties)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = eTag, + LastModifiedTime = lastModified, + RawProperties = rawProperties + }); // Act StorageResourceItemProperties result = await storageResource.GetPropertiesInternalAsync(); diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/BlobContainerClientExtensionsIntegrationTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/BlobContainerClientExtensionsIntegrationTests.cs index 08f7142a72ad3..12fc0d00aa3f1 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/BlobContainerClientExtensionsIntegrationTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/BlobContainerClientExtensionsIntegrationTests.cs @@ -223,7 +223,7 @@ public async Task StartUploadDirectoryAsync_WithOptions_Skipped() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists + CreationPreference = StorageResourceCreationMode.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -417,7 +417,7 @@ public async Task StartDownloadToDirectoryAsync_WithOptions_Skipped() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists + CreationPreference = StorageResourceCreationMode.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/BlockBlobStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/BlockBlobStorageResourceTests.cs index fc8c805934cce..0825b98566718 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/BlockBlobStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/BlockBlobStorageResourceTests.cs @@ -266,11 +266,12 @@ private async Task> CopyFromStreamInternalPreserve( // Act StorageResourceWriteToOffsetOptions copyFromStreamOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - default) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + } }; await storageResource.CopyFromStreamInternalAsync( stream: stream, @@ -627,11 +628,13 @@ private async Task> CopyFromUriInternalPreserveAsync( }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromUriInternalAsync( sourceResource: sourceResource, @@ -951,11 +954,12 @@ public async Task CopyFromUriAsync_SetProperties() // Act StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: default) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1) + } }; await destinationResource.CopyFromUriInternalAsync( sourceResource: sourceResource, @@ -1312,11 +1316,13 @@ public async Task GetPropertiesAsync_Cached() BlockBlobStorageResource storageResource = new BlockBlobStorageResource( mock.Object, - new StorageResourceItemProperties( - length, - eTag, - lastModified, - rawProperties)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = eTag, + LastModifiedTime = lastModified, + RawProperties = rawProperties + }); // Act StorageResourceItemProperties result = await storageResource.GetPropertiesInternalAsync(); @@ -1433,18 +1439,15 @@ public async Task CopyFromUriAsync_DefaultMetadata() { { DataMovementConstants.ResourceProperties.Metadata, sourceMetdata }, }; - StorageResourceItemProperties sourceProperties = new( - length, - new ETag("etag"), - DateTimeOffset.UtcNow.AddHours(-1), - rawProperties); StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: rawProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = rawProperties + } }; await destinationResource.CopyFromUriInternalAsync( sourceResource, @@ -1524,11 +1527,13 @@ await destinationResource.CopyFromStreamInternalAsync( { DataMovementConstants.ResourceProperties.CacheControl, DefaultCacheControl }, { DataMovementConstants.ResourceProperties.Metadata, metadata } }; - StorageResourceItemProperties sourceProperties = new( - completeLength, - new ETag("etag"), - DateTimeOffset.UtcNow.AddHours(-1), - rawProperties); + StorageResourceItemProperties sourceProperties = new() + { + ResourceLength = completeLength, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = rawProperties + }; await destinationResource.CompleteTransferAsync( overwrite: false, completeTransferOptions: new() { SourceProperties = sourceProperties }); diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PageBlobStorageResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PageBlobStorageResourceTests.cs index d46121298bee6..877b23c9b7fcd 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PageBlobStorageResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PageBlobStorageResourceTests.cs @@ -302,11 +302,13 @@ public async Task CopyFromStreamAsync_PropertiesDefault() }; StorageResourceWriteToOffsetOptions copyFromStreamOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromStreamInternalAsync( stream, @@ -403,11 +405,13 @@ public async Task CopyFromStreamAsync_PropertiesPreserve() }; StorageResourceWriteToOffsetOptions copyFromStreamOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromStreamInternalAsync( stream, @@ -504,11 +508,13 @@ public async Task CopyFromStreamAsync_PropertiesNoPreserve() }; StorageResourceWriteToOffsetOptions copyFromStreamOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromStreamInternalAsync( stream, @@ -722,11 +728,13 @@ public async Task CopyFromUriAsync_PropertiesDefault() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromUriInternalAsync( sourceResource.Object, @@ -830,11 +838,13 @@ public async Task CopyFromUriAsync_PropertiesPreserve() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromUriInternalAsync( sourceResource.Object, @@ -939,11 +949,13 @@ public async Task CopyFromUriAsync_PropertiesNoPreserve() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyFromUriInternalAsync( sourceResource.Object, @@ -1246,11 +1258,13 @@ public async Task CopyBlockFromUriAsync_PropertiesDefault() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyBlockFromUriInternalAsync( sourceResource.Object, @@ -1356,11 +1370,13 @@ public async Task CopyBlockFromUriAsync_PropertiesPreserve() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyBlockFromUriInternalAsync( sourceResource.Object, @@ -1466,11 +1482,13 @@ public async Task CopyBlockFromUriAsync_PropertiesNoPreserve() }; StorageResourceCopyFromUriOptions copyFromUriOptions = new() { - SourceProperties = new StorageResourceItemProperties( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + } }; await destinationResource.CopyBlockFromUriInternalAsync( sourceResource.Object, @@ -1648,11 +1666,13 @@ public async Task GetPropertiesAsync_Cached() BlockBlobStorageResource storageResource = new BlockBlobStorageResource( mock.Object, - new StorageResourceItemProperties( - length, - eTag, - lastModified, - rawProperties)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = eTag, + LastModifiedTime = lastModified, + RawProperties = rawProperties + }); // Act StorageResourceItemProperties result = await storageResource.GetPropertiesInternalAsync(); diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs index 278a223cf4839..a3e6a439edf10 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/PauseResumeTransferTests.cs @@ -248,8 +248,8 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferManager transferManager = new TransferManager(options); @@ -271,7 +271,7 @@ public async Task TryPauseTransferAsync_Id(TransferDirection transferType) // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); @@ -302,8 +302,8 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferOptions transferOptions = new TransferOptions(); @@ -325,7 +325,7 @@ public async Task TryPauseTransferAsync_TransferOperation(TransferDirection tran // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); @@ -346,13 +346,13 @@ public void TryPauseTransferAsync_Error() using DisposingLocalDirectory checkpointerDirectory = DisposingLocalDirectory.GetTestDirectory(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure }; TransferManager transferManager = new TransferManager(options); // Act / Assert - Assert.CatchAsync(async () => await transferManager.PauseTransferIfRunningAsync("bad transfer Id")); + Assert.CatchAsync(async () => await transferManager.PauseTransferAsync("bad transfer Id")); } [Ignore("https://github.com/Azure/azure-sdk-for-net/issues/35439")] @@ -372,8 +372,8 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferOptions transferOptions = new TransferOptions(); @@ -395,14 +395,14 @@ public async Task TryPauseTransferAsync_AlreadyPaused(TransferDirection transfer // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource2.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -432,8 +432,8 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferOptions transferOptions = new TransferOptions(); @@ -460,7 +460,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) // Act - Pause Job CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -470,7 +470,7 @@ public async Task PauseThenResumeTransferAsync(TransferDirection transferType) TransferOptions resumeOptions = new TransferOptions() { // Enable overwrite on resume, to overwrite destination. - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists + CreationPreference = StorageResourceCreationMode.OverwriteIfExists }; TestEventsRaised testEventRaised2 = new TestEventsRaised(resumeOptions); TransferOperation resumeTransfer = await transferManager.ResumeTransferAsync( @@ -512,8 +512,8 @@ public async Task ResumeTransferAsync(TransferDirection transferType) LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferOptions transferOptions = new TransferOptions(); @@ -540,7 +540,7 @@ public async Task ResumeTransferAsync(TransferDirection transferType) // Act - Pause Job CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -587,8 +587,8 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferManager transferManager = new TransferManager(options); @@ -619,7 +619,7 @@ public async Task ResumeTransferAsync_Options(TransferDirection transferType) // Act - Pause Job CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Act - Resume Job @@ -833,8 +833,8 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferManager transferManager = new TransferManager(options); @@ -859,7 +859,7 @@ public async Task TryPauseTransferAsync_Id_Directory(TransferDirection transferT // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); @@ -885,8 +885,8 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferManager transferManager = new TransferManager(options); @@ -911,7 +911,7 @@ public async Task TryPauseTransferAsync_TransferOperation_Directory(TransferDire // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); @@ -937,8 +937,8 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferManager transferManager = new TransferManager(options); @@ -963,14 +963,14 @@ public async Task TryPauseTransferAsync_AlreadyPaused_Directory(TransferDirectio // Act CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); CancellationTokenSource cancellationTokenSource2 = new CancellationTokenSource(TimeSpan.FromSeconds(10)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource2.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource2.Token); await testEventsRaised.AssertPausedCheck(); Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -995,8 +995,8 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferManager transferManager = new TransferManager(options); @@ -1030,7 +1030,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans // Act - Pause Job CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -1040,7 +1040,7 @@ public async Task PauseThenResumeTransferAsync_Directory(TransferDirection trans // Act - Resume Job TransferOptions resumeOptions = new() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists + CreationPreference = StorageResourceCreationMode.OverwriteIfExists }; TestEventsRaised testEventRaised2 = new TestEventsRaised(resumeOptions); TransferOperation resumeTransfer = await transferManager.ResumeTransferAsync( @@ -1083,8 +1083,8 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferManager transferManager = new TransferManager(options); @@ -1118,7 +1118,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) // Act - Pause Job CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(100)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, cancellationTokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, cancellationTokenSource.Token); // Assert - Confirm we've paused Assert.AreEqual(TransferState.Paused, transfer.Status.State); @@ -1128,7 +1128,7 @@ public async Task ResumeTransferAsync_Directory(TransferDirection transferType) // Act - Resume Job TransferOptions resumeOptions = new() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists + CreationPreference = StorageResourceCreationMode.OverwriteIfExists }; TestEventsRaised testEventsRaised2 = new TestEventsRaised(resumeOptions); TransferOperation resumeTransfer = await transferManager.ResumeTransferAsync( @@ -1178,8 +1178,8 @@ public async Task ResumeTransferAsync_Directory_Large( LocalFilesStorageResourceProvider localProvider = new(); TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerDirectory.DirectoryPath), - ErrorHandling = TransferErrorMode.ContinueOnFailure, + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerDirectory.DirectoryPath), + ErrorMode = TransferErrorMode.ContinueOnFailure, ResumeProviders = new() { blobProvider, localProvider }, }; TransferManager transferManager = new TransferManager(options); @@ -1210,7 +1210,7 @@ public async Task ResumeTransferAsync_Directory_Large( // Pause Transfer CancellationTokenSource pauseCancellation = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, pauseCancellation.Token); + await transferManager.PauseTransferAsync(transfer.Id, pauseCancellation.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Resume Transfer diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/ProgressHandlerTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/ProgressHandlerTests.cs index 15345438d30ad..449fd3b8a347e 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/ProgressHandlerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/ProgressHandlerTests.cs @@ -118,12 +118,12 @@ private async Task TransferAndAssertProgress( TransferManagerOptions transferManagerOptions = default, TransferOptions transferOptions = default, bool trackBytes = true, - StorageResourceCreationPreference createMode = StorageResourceCreationPreference.OverwriteIfExists, + StorageResourceCreationMode createMode = StorageResourceCreationMode.OverwriteIfExists, int waitTime = 30) { transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; TransferManager transferManager = new TransferManager(transferManagerOptions); @@ -209,9 +209,9 @@ await TransferAndAssertProgress( } [Test] - [TestCase(StorageResourceCreationPreference.SkipIfExists)] - [TestCase(StorageResourceCreationPreference.FailIfExists)] - public async Task ProgressHandler_Conflict(StorageResourceCreationPreference createMode) + [TestCase(StorageResourceCreationMode.SkipIfExists)] + [TestCase(StorageResourceCreationMode.FailIfExists)] + public async Task ProgressHandler_Conflict(StorageResourceCreationMode createMode) { // Arrange using DisposingLocalDirectory source = DisposingLocalDirectory.GetTestDirectory(); @@ -234,8 +234,8 @@ await TransferAndAssertProgress( destinationResource, _expectedBytesTransferred.Take(_expectedBytesTransferred.Length - 2).ToArray(), fileCount: 5, - skippedCount: createMode == StorageResourceCreationPreference.SkipIfExists ? 2 : 0, - failedCount: createMode == StorageResourceCreationPreference.FailIfExists ? 2 : 0, + skippedCount: createMode == StorageResourceCreationMode.SkipIfExists ? 2 : 0, + failedCount: createMode == StorageResourceCreationMode.FailIfExists ? 2 : 0, createMode: createMode); } @@ -279,7 +279,7 @@ public async Task ProgressHandler_Chunks(TransferDirection transferType) TransferManagerOptions transferManagerOptions = new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.StopOnAnyFailure, + ErrorMode = TransferErrorMode.StopOnAnyFailure, MaximumConcurrency = 3 }; TransferOptions transferOptions = new TransferOptions() @@ -339,7 +339,7 @@ public async Task ProgressHandler_PauseResume(int delayInMs) // Pause transfer CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); - await transferManager.PauseTransferIfRunningAsync(transfer.Id, tokenSource.Token); + await transferManager.PauseTransferAsync(transfer.Id, tokenSource.Token); Assert.AreEqual(TransferState.Paused, transfer.Status.State); // Record the current number of progress updates to use during assertions diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/StartTransferCheckpointerTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/StartTransferCheckpointerTests.cs index e4a1e3eecdde2..6ac98441d6c3a 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/StartTransferCheckpointerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/StartTransferCheckpointerTests.cs @@ -73,13 +73,13 @@ public async Task CheckpointerWithSasAsync() TransferManagerOptions managerOptions = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(disposingLocalDirectory.DirectoryPath) + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(disposingLocalDirectory.DirectoryPath) }; TransferManager transferManager = new TransferManager(managerOptions); TransferOptions transferOptions = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists + CreationPreference = StorageResourceCreationMode.FailIfExists }; // Start transfer and await for completion. This transfer will fail diff --git a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/StorageResourceEtagManagementTests.cs b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/StorageResourceEtagManagementTests.cs index b6d2d34c59b5c..e0e97403393f4 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/StorageResourceEtagManagementTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Blobs/tests/StorageResourceEtagManagementTests.cs @@ -37,7 +37,12 @@ public async Task BlockBlobMaintainsEtagForDownloads() BlobsModelFactory.BlobDownloadStreamingResult(Stream.Null, new BlobDownloadDetails()), new MockResponse(201)))); - StorageResourceItemProperties properties = new(0, etag, DateTimeOffset.UtcNow ,default); + StorageResourceItemProperties properties = new() + { + ResourceLength = 0, + ETag = etag, + LastModifiedTime = DateTimeOffset.UtcNow + }; BlockBlobStorageResource storageResource = new(mock.Object, properties, default); await storageResource.ReadStreamInternalAsync(); @@ -61,7 +66,12 @@ public async Task PageBlobMaintainsEtagForDownloads() BlobsModelFactory.BlobDownloadStreamingResult(Stream.Null, new BlobDownloadDetails()), new MockResponse(201)))); - StorageResourceItemProperties properties = new(0, etag, DateTimeOffset.UtcNow ,default); + StorageResourceItemProperties properties = new() + { + ResourceLength = 0, + ETag = etag, + LastModifiedTime = DateTimeOffset.UtcNow + }; PageBlobStorageResource storageResource = new(mock.Object, properties, default); await storageResource.ReadStreamInternalAsync(); @@ -85,7 +95,12 @@ public async Task AppendBlobMaintainsEtagForDownloads() BlobsModelFactory.BlobDownloadStreamingResult(Stream.Null, new BlobDownloadDetails()), new MockResponse(201)))); - StorageResourceItemProperties properties = new(0, etag, DateTimeOffset.UtcNow ,default); + StorageResourceItemProperties properties = new() + { + ResourceLength = 0, + ETag = etag, + LastModifiedTime = DateTimeOffset.UtcNow + }; AppendBlobStorageResource storageResource = new(mock.Object, properties, default); await storageResource.GetPropertiesInternalAsync(); @@ -110,11 +125,12 @@ public async Task BlockBlobUsesProvidedEtag() BlobsModelFactory.BlobDownloadStreamingResult(Stream.Null, new BlobDownloadDetails()), new MockResponse(201)))); - StorageResourceItemProperties resourceProperties = new( - resourceLength: default, - eTag: etag, - lastModifiedTime: DateTimeOffset.UtcNow, - properties: default); + StorageResourceItemProperties resourceProperties = new() + { + ResourceLength = default, + ETag = etag, + LastModifiedTime = DateTimeOffset.UtcNow + }; BlockBlobStorageResource storageResource = new(mock.Object, resourceProperties); await storageResource.ReadStreamInternalAsync(); @@ -138,11 +154,12 @@ public async Task PageBlobUsesProvidedEtag() BlobsModelFactory.BlobDownloadStreamingResult(Stream.Null, new BlobDownloadDetails()), new MockResponse(201)))); - StorageResourceItemProperties resourceProperties = new( - resourceLength: default, - eTag: etag, - lastModifiedTime: DateTimeOffset.UtcNow, - properties: default); + StorageResourceItemProperties resourceProperties = new() + { + ResourceLength = default, + ETag = etag, + LastModifiedTime = DateTimeOffset.UtcNow + }; PageBlobStorageResource storageResource = new(mock.Object, resourceProperties); await storageResource.ReadStreamInternalAsync(); @@ -166,7 +183,12 @@ public async Task AppendBlobUsesProvidedEtag() BlobsModelFactory.BlobDownloadStreamingResult(Stream.Null, new BlobDownloadDetails()), new MockResponse(201)))); - StorageResourceItemProperties properties = new(0, etag, DateTimeOffset.UtcNow ,default); + StorageResourceItemProperties properties = new() + { + ResourceLength = 0, + ETag = etag, + LastModifiedTime = DateTimeOffset.UtcNow + }; AppendBlobStorageResource storageResource = new(mock.Object, properties, default); await storageResource.ReadStreamInternalAsync(); diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/src/DataMovementSharesExtensions.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/src/DataMovementSharesExtensions.cs index 9cb7d338fcb60..70658628ab2d1 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/src/DataMovementSharesExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/src/DataMovementSharesExtensions.cs @@ -12,7 +12,7 @@ internal static partial class DataMovementSharesExtensions { public static ShareFileHttpHeaders GetShareFileHttpHeaders( this ShareFileStorageResourceOptions options, - Dictionary properties) + IDictionary properties) => new() { ContentType = (options?.ContentType?.Preserve ?? true) @@ -44,7 +44,7 @@ public static ShareFileHttpHeaders GetShareFileHttpHeaders( public static Metadata GetFileMetadata( this ShareFileStorageResourceOptions options, - Dictionary properties) + IDictionary properties) => (options?.FileMetadata?.Preserve ?? true) ? properties?.TryGetValue(DataMovementConstants.ResourceProperties.Metadata, out object metadata) == true ? (Metadata) metadata @@ -53,7 +53,7 @@ public static Metadata GetFileMetadata( public static string GetFilePermission( this ShareFileStorageResourceOptions options, - Dictionary properties) + IDictionary properties) => (options?.FilePermissions?.Preserve ?? false) ? properties?.TryGetValue(DataMovementConstants.ResourceProperties.FilePermissions, out object permission) == true ? (string) permission @@ -61,19 +61,19 @@ public static string GetFilePermission( : default; public static string GetSourcePermissionKey( - this Dictionary properties) + this IDictionary properties) => properties?.TryGetValue(DataMovementConstants.ResourceProperties.SourceFilePermissionKey, out object permissionKey) == true ? (string)permissionKey : default; public static string GetDestinationPermissionKey( - this Dictionary properties) + this IDictionary properties) => properties?.TryGetValue(DataMovementConstants.ResourceProperties.DestinationFilePermissionKey, out object permissionKey) == true ? (string)permissionKey : default; public static string GetPermission( - this Dictionary properties) + this IDictionary properties) => properties?.TryGetValue(DataMovementConstants.ResourceProperties.FilePermissions, out object permission) == true ? (string) permission : default; @@ -141,7 +141,7 @@ internal static ShareFileUploadRangeFromUriOptions ToShareFileUploadRangeFromUri }; private static void WriteKeyValue( - this Dictionary properties, + this IDictionary properties, string key, object value) { @@ -208,11 +208,13 @@ internal static StorageResourceItemProperties ToStorageResourceItemProperties( { rawProperties.WriteKeyValue(DataMovementConstants.ResourceProperties.CacheControl, fileProperties.CacheControl); } - return new StorageResourceItemProperties( - resourceLength: fileProperties.ContentLength, - eTag: fileProperties.ETag, - lastModifiedTime: fileProperties.LastModified, - properties: rawProperties); + return new StorageResourceItemProperties() + { + ResourceLength = fileProperties.ContentLength, + ETag = fileProperties.ETag, + LastModifiedTime = fileProperties.LastModified, + RawProperties = rawProperties + }; } internal static void AddToStorageResourceItemProperties( @@ -341,11 +343,13 @@ internal static StorageResourceReadStreamResult ToStorageResourceReadStreamResul return new StorageResourceReadStreamResult( content: info?.Content, range: ContentRange.ToHttpRange(contentRange), - properties: new StorageResourceItemProperties( - resourceLength: contentRange.Size, - eTag: info.Details.ETag, - lastModifiedTime: info.Details.LastModified, - properties: properties)); + new StorageResourceItemProperties() + { + ResourceLength = contentRange.Size, + ETag = info.Details.ETag, + LastModifiedTime = info.Details.LastModified, + RawProperties = properties + }); } internal static StorageResourceItemProperties ToResourceProperties( @@ -361,11 +365,13 @@ internal static StorageResourceItemProperties ToResourceProperties( { properties.Add(DataMovementConstants.ResourceProperties.DestinationFilePermissionKey, destinationPermissionKey); } - return new StorageResourceItemProperties( - resourceLength: shareItem?.FileSize, - eTag: shareItem?.Properties?.ETag, - lastModifiedTime: shareItem?.Properties?.LastModified, - properties: properties); + return new StorageResourceItemProperties() + { + ResourceLength = shareItem?.FileSize, + ETag = shareItem?.Properties?.ETag, + LastModifiedTime = shareItem?.Properties?.LastModified, + RawProperties = properties + }; } private static string[] ConvertContentPropertyObjectToStringArray(string contentPropertyName, object contentPropertyValue) diff --git a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ShareFileResourceTests.cs b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ShareFileResourceTests.cs index d6b1b78cd1f75..cd243160f8788 100644 --- a/sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ShareFileResourceTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement.Files.Shares/tests/ShareFileResourceTests.cs @@ -376,11 +376,13 @@ await storageResource.CopyFromStreamInternalAsync( completeLength: length, options: new() { - SourceProperties = new StorageResourceItemProperties( - length, - new ETag("eTag"), - DefaultLastWrittenOn, - sourceProperties) + SourceProperties = new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn, + RawProperties = sourceProperties + } }); return mock; @@ -826,11 +828,13 @@ public async Task CopyFromUriAsync_PropertiesDefault() await CopyFromUriAsyncPreserveProperties_Internal( length, default, - new StorageResourceItemProperties( - length, - new ETag("eTag"), - DefaultLastWrittenOn, - sourceProperties)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn, + RawProperties = sourceProperties + }); // Verify mockTuple.Item2.Verify(b => b.CreateAsync( @@ -901,11 +905,13 @@ await CopyFromUriAsyncPreserveProperties_Internal( FileChangedOn = new(true), FileMetadata = new(true) }, - new StorageResourceItemProperties( - length, - new ETag("eTag"), - DefaultLastWrittenOn, - sourceProperties)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn, + RawProperties = sourceProperties + }); // Verify mockTuple.Item2.Verify(b => b.CreateAsync( @@ -975,11 +981,13 @@ await CopyFromUriAsyncPreserveProperties_Internal( FileChangedOn = new(false), FileMetadata = new(false) }, - new StorageResourceItemProperties( - length, - new ETag("eTag"), - DefaultLastWrittenOn, - sourceProperties)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn, + RawProperties = sourceProperties + }); // Verify mockTuple.Item2.Verify(b => b.CreateAsync( @@ -1036,11 +1044,12 @@ await CopyFromUriAsyncPreserveProperties_Internal( FileChangedOn = new(DefaultFileChangedOn), FileMetadata = new(DefaultFileMetadata) }, - new StorageResourceItemProperties( - length, - new ETag("eTag"), - DefaultLastWrittenOn, - default)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn + }); // Verify mockTuple.Item2.Verify(b => b.CreateAsync( @@ -1257,11 +1266,13 @@ public async Task CopyBlockFromUriAsync_PropertiesDefault() await CopyBlockFromUriAsyncPreserveProperties_Internal( length, default, - new StorageResourceItemProperties( - length, - new ETag("eTag"), - DefaultLastWrittenOn, - sourceProperties)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn, + RawProperties = sourceProperties + }); // Assert mockTuple.Item2.Verify(b => b.CreateAsync( @@ -1332,11 +1343,13 @@ await CopyBlockFromUriAsyncPreserveProperties_Internal( FileChangedOn = new(true), FileMetadata = new(true) }, - new StorageResourceItemProperties( - length, - new ETag("eTag"), - DefaultLastWrittenOn, - sourceProperties)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn, + RawProperties = sourceProperties + }); // Verify mockTuple.Item2.Verify(b => b.CreateAsync( @@ -1406,11 +1419,13 @@ await CopyBlockFromUriAsyncPreserveProperties_Internal( FileChangedOn = new(false), FileMetadata = new(false) }, - new StorageResourceItemProperties( - length, - new ETag("eTag"), - DefaultLastWrittenOn, - sourceProperties)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn, + RawProperties = sourceProperties + }); // Verify mockTuple.Item2.Verify(b => b.CreateAsync( @@ -1468,11 +1483,12 @@ await CopyBlockFromUriAsyncPreserveProperties_Internal( FileChangedOn = new(DefaultFileChangedOn), FileMetadata = new(DefaultFileMetadata) }, - new StorageResourceItemProperties( - length, - new ETag("eTag"), - DefaultLastWrittenOn, - default)); + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn + }); // Verify mockTuple.Item2.Verify(b => b.CreateAsync( @@ -1622,15 +1638,17 @@ public async Task GetPropertiesAsync_CachedFromEnumeration() ShareFileStorageResource storageResource = new ShareFileStorageResource( mock.Object, - new StorageResourceItemProperties( - resourceLength: length, - eTag: new ETag("etag"), - lastModifiedTime: DefaultLastWrittenOn, - properties: new Dictionary + new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DefaultLastWrittenOn, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.SourceFilePermissionKey, DefaultFilePermissionKey }, { DataMovementConstants.ResourceProperties.DestinationFilePermissionKey, DefaultDestinationFilePermissionKey } - })); + } + }); // Act StorageResourceItemProperties result = await storageResource.GetPropertiesInternalAsync(); @@ -1740,14 +1758,16 @@ public async Task GetPermissionsAsync() .Returns(mockShare.Object) .Verifiable(); - StorageResourceItemProperties properties = new StorageResourceItemProperties( - 1024, - new ETag("etag"), - DateTimeOffset.UtcNow, - new Dictionary + StorageResourceItemProperties properties = new() + { + ResourceLength = 1024, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.SourceFilePermissionKey, DefaultFilePermissionKey } - }); + } + }; ShareFileStorageResource resource = new(mockFile.Object); string actualPermission = await resource.GetPermissionsInternalAsync(properties); @@ -1798,14 +1818,16 @@ public async Task SetPermissionsAsync() .Returns(mockShare.Object) .Verifiable(); - StorageResourceItemProperties properties = new StorageResourceItemProperties( - 1024, - new ETag("etag"), - DateTimeOffset.UtcNow, - new Dictionary + StorageResourceItemProperties properties = new() + { + ResourceLength = 1024, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.SourceFilePermissionKey, DefaultFilePermissionKey } - }); + } + }; ShareFileStorageResource resource = new( mockFile.Object, @@ -1833,14 +1855,16 @@ public async Task SetPermissionsAsync_NonShareFile() Mock sourceFileMock = new(); Mock mockFile = new(); - StorageResourceItemProperties properties = new StorageResourceItemProperties( - 1024, - new ETag("etag"), - DateTimeOffset.UtcNow, - new Dictionary + StorageResourceItemProperties properties = new() + { + ResourceLength = 1024, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.SourceFilePermissionKey, DefaultFilePermissionKey } - }); + } + }; ShareFileStorageResource resource = new(mockFile.Object); await resource.SetPermissionsInternalAsync( @@ -1859,14 +1883,16 @@ public async Task SetPermissionsAsync_NoPreserve() new ShareClientOptions()), new ShareFileStorageResourceOptions()); - StorageResourceItemProperties properties = new StorageResourceItemProperties( - 1024, - new ETag("etag"), - DateTimeOffset.UtcNow, - new Dictionary + StorageResourceItemProperties properties = new() + { + ResourceLength = 1024, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.SourceFilePermissionKey, DefaultFilePermissionKey } - }); + } + }; ShareFileStorageResource resource = new( shareFileClient.Object, @@ -1896,14 +1922,16 @@ public async Task SetPermissionsAsync_EmptyGetPermissions() .Returns(Task.FromResult((string)default)) .Verifiable(); - StorageResourceItemProperties properties = new StorageResourceItemProperties( - 1024, - new ETag("etag"), - DateTimeOffset.UtcNow, - new Dictionary + StorageResourceItemProperties properties = new() + { + ResourceLength = 1024, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.SourceFilePermissionKey, DefaultFilePermissionKey } - }); + } + }; ShareFileStorageResource resource = new(mockFile.Object, new ShareFileStorageResourceOptions() @@ -1926,22 +1954,26 @@ public async Task SetPermissionsAsync_PermissionsValue() new ShareFileStorageResourceOptions()); Mock mockFile = new(new Uri("https://storageaccount.file.core.windows.net/share/file1"), new ShareClientOptions()); - StorageResourceItemProperties destinationProperties = new StorageResourceItemProperties( - 1024, - new ETag("etag"), - DateTimeOffset.UtcNow, - new Dictionary + StorageResourceItemProperties destinationProperties = new() + { + ResourceLength = 1024, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.LastModified, DefaultLastModifiedOn } - }); - StorageResourceItemProperties sourceProperties = new StorageResourceItemProperties( - 1024, - new ETag("etag"), - DateTimeOffset.UtcNow, - new Dictionary + } + }; + StorageResourceItemProperties sourceProperties = new() + { + ResourceLength = 1024, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.FilePermissions, DefaultPermissions } - }); + } + }; ShareFileStorageResource resource = new(mockFile.Object, destinationProperties, @@ -1981,11 +2013,12 @@ public async Task CreateAsync() fileParentId: "93024923"), new MockResponse(200)))); ShareFileStorageResource destinationResource = new ShareFileStorageResource(mockDestination.Object); - StorageResourceItemProperties properties = new StorageResourceItemProperties( - 1024, - new ETag("etag"), - DateTimeOffset.UtcNow, - new() + StorageResourceItemProperties properties = new() + { + ResourceLength = 1024, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.ContentType, DefaultContentType }, { DataMovementConstants.ResourceProperties.ContentEncoding, DefaultContentEncoding }, @@ -1999,7 +2032,8 @@ public async Task CreateAsync() { DataMovementConstants.ResourceProperties.ChangedOnTime, DefaultFileChangedOn }, { DataMovementConstants.ResourceProperties.Metadata, DefaultFileMetadata }, { DataMovementConstants.ResourceProperties.FilePermissions, DefaultPermissions } - }); + } + }; // Act await destinationResource.CreateAsync( @@ -2062,11 +2096,12 @@ public async Task CreateAsync_PermissionKey() { FilePermissions = new(true) }); - StorageResourceItemProperties properties = new StorageResourceItemProperties( - 1024, - new ETag("etag"), - DateTimeOffset.UtcNow, - new() + StorageResourceItemProperties properties = new() + { + ResourceLength = 1024, + ETag = new("etag"), + LastModifiedTime = DateTimeOffset.UtcNow, + RawProperties = new Dictionary { { DataMovementConstants.ResourceProperties.ContentType, DefaultContentType }, { DataMovementConstants.ResourceProperties.ContentEncoding, DefaultContentEncoding }, @@ -2081,7 +2116,8 @@ public async Task CreateAsync_PermissionKey() { DataMovementConstants.ResourceProperties.Metadata, DefaultFileMetadata }, { DataMovementConstants.ResourceProperties.SourceFilePermissionKey, DefaultFilePermissionKey }, { DataMovementConstants.ResourceProperties.DestinationFilePermissionKey, DefaultDestinationFilePermissionKey } - }); + } + }; // Act await destinationResource.CreateAsync( diff --git a/sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md b/sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md index 6435b0e9f41a2..a9b81790378b5 100644 --- a/sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md +++ b/sdk/storage/Azure.Storage.DataMovement/CHANGELOG.md @@ -5,7 +5,7 @@ ### Features Added ### Breaking Changes -- Renamed the following types: +- Renamed the following types/properties: - `DataTransfer` -> `TransferOperation` - Addtionally renamed the `TransferStatus` property to `Status` - `DataTransferEventArgs` -> `TransferEventArgs` @@ -21,6 +21,17 @@ - `StorageResource.GetSourceCheckpointData` -> `StorageResource.GetSourceCheckpointDetails` - `TransferProperties.DestinationCheckpointData` -> `TransferProperties.DestinationCheckpointDetails` - `TransferProperties.SourceCheckpointData` -> `TransferProperties.SourceCheckpointDetails` + - `StorageResourceCreationPreference` -> `StorageResourceCreateMode` + - `TransferManager.PauseTransferIfRunningAsync` -> `TransferManager.PauseTransferAsync` + - `TransferManagerOptions.ErrorHandling` -> `TransferManagerOptions.ErrorMode` + - `TransferManagerOptions.CheckpointerOptions` -> `TransferManagerOptions.CheckpointStoreOptions` + - `TransferItemCompletedEventArgs.SourceResource` -> `TransferItemCompletedEventArgs.Source` and `TransferItemCompletedEventArgs.DestinationResource` -> `TransferItemCompletedEventArgs.Destination` + - `TransferItemFailedEventArgs.SourceResource` -> `TransferItemFailedEventArgs.Source` and `TransferItemFailedEventArgs.DestinationResource` -> `TransferItemFailedEventArgs.Destination` + - `TransferItemSkippedEventArgs.SourceResource` -> `TransferItemSkippedEventArgs.Source` and `TransferItemSkippedEventArgs.DestinationResource` -> `TransferItemSkippedEventArgs.Destination` + - `TransferCheckpointStoreOptions.Local` -> `TransferCheckpointStoreOptions.CreateLocalStore` + - `TransferCheckpointStoreOptions.Disabled` -> `TransferCheckpointStoreOptions.DisableCheckpoint` +- Removed properties from `StorageResourceItemProperties` constructor since properties are settable. +- Changed type of `StorageResourceItemProperties.RawProperties` to `IDictionary`. ### Bugs Fixed - Fixed bug where adding multiple transfers in parallel could cause a collision (`InvalidOperationException`) in the data transfers stored within the `TransferManager`. diff --git a/sdk/storage/Azure.Storage.DataMovement/README.md b/sdk/storage/Azure.Storage.DataMovement/README.md index 1ba0adbbb872d..9716980ddae20 100644 --- a/sdk/storage/Azure.Storage.DataMovement/README.md +++ b/sdk/storage/Azure.Storage.DataMovement/README.md @@ -186,7 +186,7 @@ async Task ListenToTransfersAsync(TransferManager transferMan transferOptions.ItemTransferCompleted += (TransferItemCompletedEventArgs args) => { using StreamWriter logStream = File.AppendText(logFile); - logStream.WriteLine($"File Completed Transfer: {args.SourceResource.Uri.LocalPath}"); + logStream.WriteLine($"File Completed Transfer: {args.Source.Uri.LocalPath}"); return Task.CompletedTask; }; return await transferManager.StartTransferAsync( @@ -227,7 +227,7 @@ await transferOperation.PauseAsync(); ``` ```C# Snippet:PauseFromManager -await transferManager.PauseTransferIfRunningAsync(transferId); +await transferManager.PauseTransferAsync(transferId); ``` ### Handling Failed Transfers @@ -258,8 +258,8 @@ transferOptions.ItemTransferFailed += (TransferItemFailedEventArgs args) => // Specifying specific resources that failed, since its a directory transfer // maybe only one file failed out of many logStream.WriteLine($"Exception occurred with TransferId: {args.TransferId}," + - $"Source Resource: {args.SourceResource.Uri.AbsoluteUri}, +" + - $"Destination Resource: {args.DestinationResource.Uri.AbsoluteUri}," + + $"Source Resource: {args.Source.Uri.AbsoluteUri}, +" + + $"Destination Resource: {args.Destination.Uri.AbsoluteUri}," + $"Exception Message: {args.Exception.Message}"); } return Task.CompletedTask; diff --git a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net6.0.cs b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net6.0.cs index e268bd5bb7f09..91581a4295260 100644 --- a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net6.0.cs +++ b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net6.0.cs @@ -69,7 +69,7 @@ public StorageResourceCopyFromUriOptions() { } public Azure.HttpAuthorization SourceAuthentication { get { throw null; } set { } } public Azure.Storage.DataMovement.StorageResourceItemProperties SourceProperties { get { throw null; } set { } } } - public enum StorageResourceCreationPreference + public enum StorageResourceCreationMode { Default = 0, FailIfExists = 1, @@ -99,11 +99,10 @@ protected StorageResourceItem() { } } public partial class StorageResourceItemProperties { - protected StorageResourceItemProperties() { } - public StorageResourceItemProperties(long? resourceLength, Azure.ETag? eTag, System.DateTimeOffset? lastModifiedTime, System.Collections.Generic.Dictionary properties) { } + public StorageResourceItemProperties() { } public Azure.ETag? ETag { get { throw null; } set { } } public System.DateTimeOffset? LastModifiedTime { get { throw null; } set { } } - public System.Collections.Generic.Dictionary RawProperties { get { throw null; } set { } } + public System.Collections.Generic.IDictionary RawProperties { get { throw null; } set { } } public long? ResourceLength { get { throw null; } set { } } } public abstract partial class StorageResourceProvider @@ -132,8 +131,8 @@ public StorageResourceWriteToOffsetOptions() { } public partial class TransferCheckpointStoreOptions { internal TransferCheckpointStoreOptions() { } - public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions Disabled() { throw null; } - public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions Local(string localCheckpointerPath) { throw null; } + public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions CreateLocalStore(string localCheckpointPath) { throw null; } + public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions DisableCheckpoint() { throw null; } } [System.FlagsAttribute] public enum TransferErrorMode @@ -149,21 +148,21 @@ public abstract partial class TransferEventArgs : Azure.SyncAsyncEventArgs public partial class TransferItemCompletedEventArgs : Azure.Storage.DataMovement.TransferEventArgs { public TransferItemCompletedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Destination { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Source { get { throw null; } } } public partial class TransferItemFailedEventArgs : Azure.Storage.DataMovement.TransferEventArgs { public TransferItemFailedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, System.Exception exception, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResource DestinationResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResource Destination { get { throw null; } } public System.Exception Exception { get { throw null; } } - public Azure.Storage.DataMovement.StorageResource SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResource Source { get { throw null; } } } public partial class TransferItemSkippedEventArgs : Azure.Storage.DataMovement.TransferEventArgs { public TransferItemSkippedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Destination { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Source { get { throw null; } } } public partial class TransferManager : System.IAsyncDisposable { @@ -171,7 +170,7 @@ protected TransferManager() { } public TransferManager(Azure.Storage.DataMovement.TransferManagerOptions options = null) { } public virtual System.Collections.Generic.IAsyncEnumerable GetResumableTransfersAsync([System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Collections.Generic.IAsyncEnumerable GetTransfersAsync(System.Collections.Generic.ICollection filterByStatus = null, [System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task PauseTransferIfRunningAsync(string transferId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task PauseTransferAsync(string transferId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> ResumeAllTransfersAsync(Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task ResumeTransferAsync(string transferId, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task StartTransferAsync(Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -180,9 +179,9 @@ public TransferManager(Azure.Storage.DataMovement.TransferManagerOptions options public partial class TransferManagerOptions { public TransferManagerOptions() { } - public Azure.Storage.DataMovement.TransferCheckpointStoreOptions CheckpointerOptions { get { throw null; } set { } } + public Azure.Storage.DataMovement.TransferCheckpointStoreOptions CheckpointStoreOptions { get { throw null; } set { } } public Azure.Core.DiagnosticsOptions Diagnostics { get { throw null; } } - public Azure.Storage.DataMovement.TransferErrorMode ErrorHandling { get { throw null; } set { } } + public Azure.Storage.DataMovement.TransferErrorMode ErrorMode { get { throw null; } set { } } public int? MaximumConcurrency { get { throw null; } set { } } public System.Collections.Generic.List ResumeProviders { get { throw null; } set { } } } @@ -199,7 +198,7 @@ internal TransferOperation() { } public partial class TransferOptions : System.IEquatable { public TransferOptions() { } - public Azure.Storage.DataMovement.StorageResourceCreationPreference CreationPreference { get { throw null; } set { } } + public Azure.Storage.DataMovement.StorageResourceCreationMode CreationPreference { get { throw null; } set { } } public long? InitialTransferSize { get { throw null; } set { } } public long? MaximumTransferChunkSize { get { throw null; } set { } } public Azure.Storage.DataMovement.ProgressHandlerOptions ProgressHandlerOptions { get { throw null; } set { } } diff --git a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net8.0.cs b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net8.0.cs index e268bd5bb7f09..91581a4295260 100644 --- a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net8.0.cs +++ b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.net8.0.cs @@ -69,7 +69,7 @@ public StorageResourceCopyFromUriOptions() { } public Azure.HttpAuthorization SourceAuthentication { get { throw null; } set { } } public Azure.Storage.DataMovement.StorageResourceItemProperties SourceProperties { get { throw null; } set { } } } - public enum StorageResourceCreationPreference + public enum StorageResourceCreationMode { Default = 0, FailIfExists = 1, @@ -99,11 +99,10 @@ protected StorageResourceItem() { } } public partial class StorageResourceItemProperties { - protected StorageResourceItemProperties() { } - public StorageResourceItemProperties(long? resourceLength, Azure.ETag? eTag, System.DateTimeOffset? lastModifiedTime, System.Collections.Generic.Dictionary properties) { } + public StorageResourceItemProperties() { } public Azure.ETag? ETag { get { throw null; } set { } } public System.DateTimeOffset? LastModifiedTime { get { throw null; } set { } } - public System.Collections.Generic.Dictionary RawProperties { get { throw null; } set { } } + public System.Collections.Generic.IDictionary RawProperties { get { throw null; } set { } } public long? ResourceLength { get { throw null; } set { } } } public abstract partial class StorageResourceProvider @@ -132,8 +131,8 @@ public StorageResourceWriteToOffsetOptions() { } public partial class TransferCheckpointStoreOptions { internal TransferCheckpointStoreOptions() { } - public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions Disabled() { throw null; } - public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions Local(string localCheckpointerPath) { throw null; } + public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions CreateLocalStore(string localCheckpointPath) { throw null; } + public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions DisableCheckpoint() { throw null; } } [System.FlagsAttribute] public enum TransferErrorMode @@ -149,21 +148,21 @@ public abstract partial class TransferEventArgs : Azure.SyncAsyncEventArgs public partial class TransferItemCompletedEventArgs : Azure.Storage.DataMovement.TransferEventArgs { public TransferItemCompletedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Destination { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Source { get { throw null; } } } public partial class TransferItemFailedEventArgs : Azure.Storage.DataMovement.TransferEventArgs { public TransferItemFailedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, System.Exception exception, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResource DestinationResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResource Destination { get { throw null; } } public System.Exception Exception { get { throw null; } } - public Azure.Storage.DataMovement.StorageResource SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResource Source { get { throw null; } } } public partial class TransferItemSkippedEventArgs : Azure.Storage.DataMovement.TransferEventArgs { public TransferItemSkippedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Destination { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Source { get { throw null; } } } public partial class TransferManager : System.IAsyncDisposable { @@ -171,7 +170,7 @@ protected TransferManager() { } public TransferManager(Azure.Storage.DataMovement.TransferManagerOptions options = null) { } public virtual System.Collections.Generic.IAsyncEnumerable GetResumableTransfersAsync([System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Collections.Generic.IAsyncEnumerable GetTransfersAsync(System.Collections.Generic.ICollection filterByStatus = null, [System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task PauseTransferIfRunningAsync(string transferId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task PauseTransferAsync(string transferId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> ResumeAllTransfersAsync(Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task ResumeTransferAsync(string transferId, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task StartTransferAsync(Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -180,9 +179,9 @@ public TransferManager(Azure.Storage.DataMovement.TransferManagerOptions options public partial class TransferManagerOptions { public TransferManagerOptions() { } - public Azure.Storage.DataMovement.TransferCheckpointStoreOptions CheckpointerOptions { get { throw null; } set { } } + public Azure.Storage.DataMovement.TransferCheckpointStoreOptions CheckpointStoreOptions { get { throw null; } set { } } public Azure.Core.DiagnosticsOptions Diagnostics { get { throw null; } } - public Azure.Storage.DataMovement.TransferErrorMode ErrorHandling { get { throw null; } set { } } + public Azure.Storage.DataMovement.TransferErrorMode ErrorMode { get { throw null; } set { } } public int? MaximumConcurrency { get { throw null; } set { } } public System.Collections.Generic.List ResumeProviders { get { throw null; } set { } } } @@ -199,7 +198,7 @@ internal TransferOperation() { } public partial class TransferOptions : System.IEquatable { public TransferOptions() { } - public Azure.Storage.DataMovement.StorageResourceCreationPreference CreationPreference { get { throw null; } set { } } + public Azure.Storage.DataMovement.StorageResourceCreationMode CreationPreference { get { throw null; } set { } } public long? InitialTransferSize { get { throw null; } set { } } public long? MaximumTransferChunkSize { get { throw null; } set { } } public Azure.Storage.DataMovement.ProgressHandlerOptions ProgressHandlerOptions { get { throw null; } set { } } diff --git a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.netstandard2.0.cs b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.netstandard2.0.cs index e268bd5bb7f09..91581a4295260 100644 --- a/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.netstandard2.0.cs +++ b/sdk/storage/Azure.Storage.DataMovement/api/Azure.Storage.DataMovement.netstandard2.0.cs @@ -69,7 +69,7 @@ public StorageResourceCopyFromUriOptions() { } public Azure.HttpAuthorization SourceAuthentication { get { throw null; } set { } } public Azure.Storage.DataMovement.StorageResourceItemProperties SourceProperties { get { throw null; } set { } } } - public enum StorageResourceCreationPreference + public enum StorageResourceCreationMode { Default = 0, FailIfExists = 1, @@ -99,11 +99,10 @@ protected StorageResourceItem() { } } public partial class StorageResourceItemProperties { - protected StorageResourceItemProperties() { } - public StorageResourceItemProperties(long? resourceLength, Azure.ETag? eTag, System.DateTimeOffset? lastModifiedTime, System.Collections.Generic.Dictionary properties) { } + public StorageResourceItemProperties() { } public Azure.ETag? ETag { get { throw null; } set { } } public System.DateTimeOffset? LastModifiedTime { get { throw null; } set { } } - public System.Collections.Generic.Dictionary RawProperties { get { throw null; } set { } } + public System.Collections.Generic.IDictionary RawProperties { get { throw null; } set { } } public long? ResourceLength { get { throw null; } set { } } } public abstract partial class StorageResourceProvider @@ -132,8 +131,8 @@ public StorageResourceWriteToOffsetOptions() { } public partial class TransferCheckpointStoreOptions { internal TransferCheckpointStoreOptions() { } - public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions Disabled() { throw null; } - public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions Local(string localCheckpointerPath) { throw null; } + public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions CreateLocalStore(string localCheckpointPath) { throw null; } + public static Azure.Storage.DataMovement.TransferCheckpointStoreOptions DisableCheckpoint() { throw null; } } [System.FlagsAttribute] public enum TransferErrorMode @@ -149,21 +148,21 @@ public abstract partial class TransferEventArgs : Azure.SyncAsyncEventArgs public partial class TransferItemCompletedEventArgs : Azure.Storage.DataMovement.TransferEventArgs { public TransferItemCompletedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Destination { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Source { get { throw null; } } } public partial class TransferItemFailedEventArgs : Azure.Storage.DataMovement.TransferEventArgs { public TransferItemFailedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, System.Exception exception, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResource DestinationResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResource Destination { get { throw null; } } public System.Exception Exception { get { throw null; } } - public Azure.Storage.DataMovement.StorageResource SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResource Source { get { throw null; } } } public partial class TransferItemSkippedEventArgs : Azure.Storage.DataMovement.TransferEventArgs { public TransferItemSkippedEventArgs(string transferId, Azure.Storage.DataMovement.StorageResourceItem sourceResource, Azure.Storage.DataMovement.StorageResourceItem destinationResource, bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken) : base (default(string), default(bool), default(System.Threading.CancellationToken)) { } - public Azure.Storage.DataMovement.StorageResourceItem DestinationResource { get { throw null; } } - public Azure.Storage.DataMovement.StorageResourceItem SourceResource { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Destination { get { throw null; } } + public Azure.Storage.DataMovement.StorageResourceItem Source { get { throw null; } } } public partial class TransferManager : System.IAsyncDisposable { @@ -171,7 +170,7 @@ protected TransferManager() { } public TransferManager(Azure.Storage.DataMovement.TransferManagerOptions options = null) { } public virtual System.Collections.Generic.IAsyncEnumerable GetResumableTransfersAsync([System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Collections.Generic.IAsyncEnumerable GetTransfersAsync(System.Collections.Generic.ICollection filterByStatus = null, [System.Runtime.CompilerServices.EnumeratorCancellationAttribute] System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task PauseTransferIfRunningAsync(string transferId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task PauseTransferAsync(string transferId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> ResumeAllTransfersAsync(Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task ResumeTransferAsync(string transferId, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task StartTransferAsync(Azure.Storage.DataMovement.StorageResource sourceResource, Azure.Storage.DataMovement.StorageResource destinationResource, Azure.Storage.DataMovement.TransferOptions transferOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -180,9 +179,9 @@ public TransferManager(Azure.Storage.DataMovement.TransferManagerOptions options public partial class TransferManagerOptions { public TransferManagerOptions() { } - public Azure.Storage.DataMovement.TransferCheckpointStoreOptions CheckpointerOptions { get { throw null; } set { } } + public Azure.Storage.DataMovement.TransferCheckpointStoreOptions CheckpointStoreOptions { get { throw null; } set { } } public Azure.Core.DiagnosticsOptions Diagnostics { get { throw null; } } - public Azure.Storage.DataMovement.TransferErrorMode ErrorHandling { get { throw null; } set { } } + public Azure.Storage.DataMovement.TransferErrorMode ErrorMode { get { throw null; } set { } } public int? MaximumConcurrency { get { throw null; } set { } } public System.Collections.Generic.List ResumeProviders { get { throw null; } set { } } } @@ -199,7 +198,7 @@ internal TransferOperation() { } public partial class TransferOptions : System.IEquatable { public TransferOptions() { } - public Azure.Storage.DataMovement.StorageResourceCreationPreference CreationPreference { get { throw null; } set { } } + public Azure.Storage.DataMovement.StorageResourceCreationMode CreationPreference { get { throw null; } set { } } public long? InitialTransferSize { get { throw null; } set { } } public long? MaximumTransferChunkSize { get { throw null; } set { } } public Azure.Storage.DataMovement.ProgressHandlerOptions ProgressHandlerOptions { get { throw null; } set { } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/CheckpointerExtensions.cs b/sdk/storage/Azure.Storage.DataMovement/src/CheckpointerExtensions.cs index 7611407a24f5d..865e1cf7cda3b 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/CheckpointerExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/CheckpointerExtensions.cs @@ -19,7 +19,7 @@ internal static ITransferCheckpointer BuildCheckpointer(TransferCheckpointStoreO } else { - return new LocalTransferCheckpointer(options?.CheckpointerPath); + return new LocalTransferCheckpointer(options?.CheckpointPath); } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/JobPartFailureType.cs b/sdk/storage/Azure.Storage.DataMovement/src/JobPartFailureType.cs index 652a825396dfa..d7726fd24f448 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/JobPartFailureType.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/JobPartFailureType.cs @@ -15,8 +15,8 @@ internal enum JobPartFailureType AccessDenied = 3, /// - /// If the storage resource already exists and - /// or was not enabled, then it's a failure caused + /// If the storage resource already exists and + /// or was not enabled, then it's a failure caused /// by the file already existing. /// CannotOvewrite = 2, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/JobPartInternal.cs b/sdk/storage/Azure.Storage.DataMovement/src/JobPartInternal.cs index 85a732a68a62d..98675e8eecc6a 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/JobPartInternal.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/JobPartInternal.cs @@ -60,7 +60,7 @@ internal abstract class JobPartInternal /// /// Determines how files are created and overwrite behavior for files that already exists. /// - internal StorageResourceCreationPreference _createMode; + internal StorageResourceCreationMode _createMode; /// /// If a failure occurred during a job, this defines the type of failure. @@ -146,7 +146,7 @@ internal JobPartInternal( long? transferChunkSize, long? initialTransferSize, TransferErrorMode errorHandling, - StorageResourceCreationPreference createMode, + StorageResourceCreationMode createMode, ITransferCheckpointer checkpointer, TransferProgressTracker progressTracker, ArrayPool arrayPool, @@ -190,8 +190,8 @@ internal JobPartInternal( transferChunkSize ?? DataMovementConstants.DefaultChunkSize, _destinationResource.MaxSupportedChunkSize); // Set the default create mode - _createMode = createMode == StorageResourceCreationPreference.Default ? - StorageResourceCreationPreference.FailIfExists : createMode; + _createMode = createMode == StorageResourceCreationMode.Default ? + StorageResourceCreationMode.FailIfExists : createMode; Length = length; _currentChunkCount = 0; diff --git a/sdk/storage/Azure.Storage.DataMovement/src/JobPlan/JobPartPlanHeader.cs b/sdk/storage/Azure.Storage.DataMovement/src/JobPlan/JobPartPlanHeader.cs index ddb4cf65cb1d9..5025552fdf41d 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/JobPlan/JobPartPlanHeader.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/JobPlan/JobPartPlanHeader.cs @@ -53,7 +53,7 @@ internal class JobPartPlanHeader /// /// The resource creation preference. /// - public StorageResourceCreationPreference CreatePreference; + public StorageResourceCreationMode CreatePreference; /// /// Ths initial transfer size for the transfer. @@ -84,7 +84,7 @@ public JobPartPlanHeader( string destinationTypeId, string sourcePath, string destinationPath, - StorageResourceCreationPreference createPreference, + StorageResourceCreationMode createPreference, long initialTransferSize, long chunkSize, byte priority, @@ -227,7 +227,7 @@ public static JobPartPlanHeader Deserialize(Stream stream) int destinationPathLength = reader.ReadInt32(); // CreatePreference - StorageResourceCreationPreference createPreference = (StorageResourceCreationPreference)reader.ReadByte(); + StorageResourceCreationMode createPreference = (StorageResourceCreationMode)reader.ReadByte(); // InitialTransferSize long initialTransferSize = reader.ReadInt64(); diff --git a/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceJobPart.cs b/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceJobPart.cs index 34d704971ef34..9aed96530aab7 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceJobPart.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/ServiceToServiceJobPart.cs @@ -91,7 +91,7 @@ private ServiceToServiceJobPart( TransferStatus jobPartStatus, long initialTransferSize, long transferChunkSize, - StorageResourceCreationPreference createPreference) + StorageResourceCreationMode createPreference) : base(transferOperation: job._transferOperation, partNumber: partNumber, sourceResource: sourceResource, @@ -166,7 +166,7 @@ public static ServiceToServiceJobPart CreateJobPartFromCheckpoint( TransferStatus jobPartStatus, long initialTransferSize, long transferChunkSize, - StorageResourceCreationPreference createPreference) + StorageResourceCreationMode createPreference) { return new ServiceToServiceJobPart( job: job, @@ -270,7 +270,7 @@ internal async Task StartSingleCallCopy(long completeLength) await _destinationResource.CopyFromUriAsync( sourceResource: _sourceResource, - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, completeLength: completeLength, options: options, cancellationToken: _cancellationToken).ConfigureAwait(false); @@ -279,13 +279,13 @@ await _destinationResource.CopyFromUriAsync( await OnTransferStateChangedAsync(TransferState.Completed).ConfigureAwait(false); } catch (RequestFailedException exception) - when (_createMode == StorageResourceCreationPreference.SkipIfExists + when (_createMode == StorageResourceCreationMode.SkipIfExists && exception.ErrorCode == "BlobAlreadyExists") { await InvokeSkippedArgAsync().ConfigureAwait(false); } catch (InvalidOperationException ex) - when (_createMode == StorageResourceCreationPreference.SkipIfExists + when (_createMode == StorageResourceCreationMode.SkipIfExists && ex.Message.Contains("Cannot overwrite file.")) { await InvokeSkippedArgAsync().ConfigureAwait(false); @@ -309,7 +309,7 @@ internal async Task CreateDestinationResource(long length, long blockSize) await GetCopyFromUriOptionsAsync(_cancellationToken).ConfigureAwait(false); await _destinationResource.CopyBlockFromUriAsync( sourceResource: _sourceResource, - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, range: new HttpRange(0, blockSize), completeLength: length, options: options, @@ -326,7 +326,7 @@ await _destinationResource.CopyBlockFromUriAsync( return true; } catch (RequestFailedException exception) - when (_createMode == StorageResourceCreationPreference.SkipIfExists + when (_createMode == StorageResourceCreationMode.SkipIfExists && exception.ErrorCode == "BlobAlreadyExists") { await InvokeSkippedArgAsync().ConfigureAwait(false); @@ -361,7 +361,7 @@ internal async Task CompleteTransferAsync(StorageResourceItemProperties sourcePr { // Apply necessary transfer completions on the destination. await _destinationResource.CompleteTransferAsync( - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, completeTransferOptions: new() { SourceProperties = sourceProperties }, cancellationToken: _cancellationToken).ConfigureAwait(false); @@ -433,7 +433,7 @@ internal async Task PutBlockFromUri( await GetCopyFromUriOptionsAsync(_cancellationToken).ConfigureAwait(false); await _destinationResource.CopyBlockFromUriAsync( sourceResource: _sourceResource, - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, range: new HttpRange(offset, blockLength), completeLength: expectedLength, options: options, @@ -449,12 +449,12 @@ await _commitBlockHandler.QueueChunkAsync(new QueueStageChunkArgs( } } catch (RequestFailedException ex) - when (_createMode == StorageResourceCreationPreference.OverwriteIfExists + when (_createMode == StorageResourceCreationMode.OverwriteIfExists && ex.ErrorCode == "BlobAlreadyExists") { // For Block Blobs this is a one off case because we don't create the blob // before uploading to it. - if (_createMode == StorageResourceCreationPreference.FailIfExists) + if (_createMode == StorageResourceCreationMode.FailIfExists) { await InvokeFailedArgAsync(ex).ConfigureAwait(false); } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataMovementExtensions.cs b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataMovementExtensions.cs index b0ae1a9eb9158..61c922410c416 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataMovementExtensions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/Shared/DataMovementExtensions.cs @@ -14,11 +14,12 @@ internal static StorageResourceItemProperties ToStorageResourceProperties(this F { Dictionary properties = new Dictionary(); - return new StorageResourceItemProperties( - resourceLength: fileInfo.Length, - eTag: default, - lastModifiedTime: fileInfo.LastWriteTimeUtc, - properties: properties); + return new StorageResourceItemProperties() + { + ResourceLength = fileInfo.Length, + LastModifiedTime = fileInfo.LastWriteTimeUtc, + RawProperties = properties + }; } public static StreamToUriJobPart ToStreamToUriJobPartAsync( @@ -30,8 +31,8 @@ public static StreamToUriJobPart ToStreamToUriJobPartAsync( // Override header values if options were specified by user. long initialTransferSize = baseJob._initialTransferSize ?? header.InitialTransferSize; long transferChunkSize = baseJob._maximumTransferChunkSize ?? header.ChunkSize; - StorageResourceCreationPreference createPreference = - baseJob._creationPreference != StorageResourceCreationPreference.Default ? + StorageResourceCreationMode createPreference = + baseJob._creationPreference != StorageResourceCreationMode.Default ? baseJob._creationPreference : header.CreatePreference; StreamToUriJobPart jobPart = StreamToUriJobPart.CreateJobPartFromCheckpoint( @@ -59,8 +60,8 @@ public static ServiceToServiceJobPart ToServiceToServiceJobPartAsync( // Override header values if options were specified by user. long initialTransferSize = baseJob._initialTransferSize ?? header.InitialTransferSize; long transferChunkSize = baseJob._maximumTransferChunkSize ?? header.ChunkSize; - StorageResourceCreationPreference createPreference = - baseJob._creationPreference != StorageResourceCreationPreference.Default ? + StorageResourceCreationMode createPreference = + baseJob._creationPreference != StorageResourceCreationMode.Default ? baseJob._creationPreference : header.CreatePreference; ServiceToServiceJobPart jobPart = ServiceToServiceJobPart.CreateJobPartFromCheckpoint( @@ -88,8 +89,8 @@ public static UriToStreamJobPart ToUriToStreamJobPartAsync( // Override header values if options were specified by user. long initialTransferSize = baseJob._initialTransferSize ?? header.InitialTransferSize; long transferChunkSize = baseJob._maximumTransferChunkSize ?? header.ChunkSize; - StorageResourceCreationPreference createPreference = - baseJob._creationPreference != StorageResourceCreationPreference.Default ? + StorageResourceCreationMode createPreference = + baseJob._creationPreference != StorageResourceCreationMode.Default ? baseJob._creationPreference : header.CreatePreference; UriToStreamJobPart jobPart = UriToStreamJobPart.CreateJobPartFromCheckpoint( @@ -121,8 +122,8 @@ public static StreamToUriJobPart ToStreamToUriJobPartAsync( // Override header values if options were specified by user. long initialTransferSize = baseJob._initialTransferSize ?? header.InitialTransferSize; long transferChunkSize = baseJob._maximumTransferChunkSize ?? header.ChunkSize; - StorageResourceCreationPreference createPreference = - baseJob._creationPreference != StorageResourceCreationPreference.Default ? + StorageResourceCreationMode createPreference = + baseJob._creationPreference != StorageResourceCreationMode.Default ? baseJob._creationPreference : header.CreatePreference; StreamToUriJobPart jobPart = StreamToUriJobPart.CreateJobPartFromCheckpoint( @@ -152,8 +153,8 @@ public static ServiceToServiceJobPart ToServiceToServiceJobPartAsync( // Override header values if options were specified by user. long initialTransferSize = baseJob._initialTransferSize ?? header.InitialTransferSize; long transferChunkSize = baseJob._maximumTransferChunkSize ?? header.ChunkSize; - StorageResourceCreationPreference createPreference = - baseJob._creationPreference != StorageResourceCreationPreference.Default ? + StorageResourceCreationMode createPreference = + baseJob._creationPreference != StorageResourceCreationMode.Default ? baseJob._creationPreference : header.CreatePreference; ServiceToServiceJobPart jobPart = ServiceToServiceJobPart.CreateJobPartFromCheckpoint( @@ -186,8 +187,8 @@ public static UriToStreamJobPart ToUriToStreamJobPartAsync( // Override header values if options were specified by user. long initialTransferSize = baseJob._initialTransferSize ?? header.InitialTransferSize; long transferChunkSize = baseJob._maximumTransferChunkSize ?? header.ChunkSize; - StorageResourceCreationPreference createPreference = - baseJob._creationPreference != StorageResourceCreationPreference.Default ? + StorageResourceCreationMode createPreference = + baseJob._creationPreference != StorageResourceCreationMode.Default ? baseJob._creationPreference : header.CreatePreference; UriToStreamJobPart jobPart = UriToStreamJobPart.CreateJobPartFromCheckpoint( diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCreationPreference.cs b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCreationMode.cs similarity index 68% rename from sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCreationPreference.cs rename to sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCreationMode.cs index 5de453473b787..34acace71ba54 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCreationPreference.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceCreationMode.cs @@ -6,21 +6,22 @@ namespace Azure.Storage.DataMovement /// /// Defines the behavior when a transfer resource already exists. /// - public enum StorageResourceCreationPreference + public enum StorageResourceCreationMode { /// - /// The default value will be when - /// starting a new transfer. - /// When resuming a transfer, the value will default to the value used when first starting - /// the transfer for all resources that were successfully enumerated and the regular default - /// for any remaining resources. + /// The default value. This will be or, when resuming a transfer, it + /// will use the value that was used when first starting the transfer. Any other value will override + /// the behavior on resume. + /// + /// NOTE: If a transfer was paused/stopped before all resources were enumerated, any unenumerated + /// resource will use the value of on resume. /// Default = 0, /// /// If the resource already exists in the destination path, a failure will be thrown. /// - /// The value for will determine if + /// The value for will determine if /// the transfer continues after the failure or not. /// FailIfExists = 1, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceItemProperties.cs b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceItemProperties.cs index 8fddff610829a..b43add6465201 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceItemProperties.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StorageResourceItemProperties.cs @@ -7,7 +7,7 @@ namespace Azure.Storage.DataMovement { /// - /// Properties of a Storage Resource + /// Properties of a Storage Resource. /// public class StorageResourceItemProperties { @@ -29,33 +29,14 @@ public class StorageResourceItemProperties /// /// Dictionary of the properties associated with this resource. /// - public Dictionary RawProperties { get; set; } + public IDictionary RawProperties { get; set; } /// /// Base constructor for mocking. /// - protected StorageResourceItemProperties() + public StorageResourceItemProperties() { RawProperties = new Dictionary(); } - - /// - /// Constructor for StorageResourceProperties - /// - /// - /// - /// - /// - public StorageResourceItemProperties( - long? resourceLength, - ETag? eTag, - DateTimeOffset? lastModifiedTime, - Dictionary properties) - { - ResourceLength = resourceLength; - ETag = eTag; - LastModifiedTime = lastModifiedTime; - RawProperties = properties != default ? properties : new(); - } } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriJobPart.cs b/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriJobPart.cs index c8036f60aa138..79715b83e071e 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriJobPart.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/StreamToUriJobPart.cs @@ -90,7 +90,7 @@ private StreamToUriJobPart( TransferStatus jobPartStatus, long initialTransferSize, long transferChunkSize, - StorageResourceCreationPreference createPreference) + StorageResourceCreationMode createPreference) : base(transferOperation: job._transferOperation, partNumber: partNumber, sourceResource: sourceResource, @@ -165,7 +165,7 @@ public static StreamToUriJobPart CreateJobPartFromCheckpoint( TransferStatus jobPartStatus, long initialTransferSize, long transferChunkSize, - StorageResourceCreationPreference createPreference) + StorageResourceCreationMode createPreference) { return new StreamToUriJobPart( job: job, @@ -280,12 +280,12 @@ await InitialUploadCall( return !singleCall; } catch (RequestFailedException r) - when (r.ErrorCode == "BlobAlreadyExists" && _createMode == StorageResourceCreationPreference.SkipIfExists) + when (r.ErrorCode == "BlobAlreadyExists" && _createMode == StorageResourceCreationMode.SkipIfExists) { await InvokeSkippedArgAsync().ConfigureAwait(false); } catch (InvalidOperationException i) - when (i.Message.Contains("Cannot overwrite file.") && _createMode == StorageResourceCreationPreference.SkipIfExists) + when (i.Message.Contains("Cannot overwrite file.") && _createMode == StorageResourceCreationMode.SkipIfExists) { await InvokeSkippedArgAsync().ConfigureAwait(false); } @@ -317,7 +317,7 @@ private async Task InitialUploadCall( { await _destinationResource.CopyFromStreamAsync( stream: stream, - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, streamLength: blockSize, completeLength: expectedLength, options: new() @@ -351,7 +351,7 @@ await _destinationResource.CopyFromStreamAsync( await _destinationResource.CopyFromStreamAsync( stream: slicedStream, streamLength: blockSize, - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, completeLength: expectedLength, options: new() { @@ -402,7 +402,7 @@ internal async Task StageBlockInternal( await _destinationResource.CopyFromStreamAsync( stream: slicedStream, streamLength: blockLength, - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, completeLength: completeLength, options: new StorageResourceWriteToOffsetOptions() { @@ -436,7 +436,7 @@ internal async Task CompleteTransferAsync(StorageResourceItemProperties sourcePr // Apply necessary transfer completions on the destination. await _destinationResource.CompleteTransferAsync( - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, completeTransferOptions: new() { SourceProperties = sourceProperties }, cancellationToken: _cancellationToken).ConfigureAwait(false); diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointStoreOptions.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointStoreOptions.cs index befb9dbc7ceb7..87a8cc3d423e1 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointStoreOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferCheckpointStoreOptions.cs @@ -17,34 +17,34 @@ public class TransferCheckpointStoreOptions /// /// The folder where the checkpoint information will be stored. /// - internal string CheckpointerPath { get; private set; } + internal string CheckpointPath { get; private set; } /// /// Sets the checkpoint options to disable transfer checkpointing. /// NOTE: All pause/resume functionality will be disabled. /// /// - public static TransferCheckpointStoreOptions Disabled() + public static TransferCheckpointStoreOptions DisableCheckpoint() { return new TransferCheckpointStoreOptions(false, default); } /// - /// Sets the checkpointer options to use a Local Checkpointer where + /// Sets the checkpoint options to use a Local Checkpointer where /// the checkpoint information is stored at a local folder. /// - /// + /// /// The local folder where the checkpoint information will be stored. /// - public static TransferCheckpointStoreOptions Local(string localCheckpointerPath) + public static TransferCheckpointStoreOptions CreateLocalStore(string localCheckpointPath) { - return new TransferCheckpointStoreOptions(true, localCheckpointerPath); + return new TransferCheckpointStoreOptions(true, localCheckpointPath); } - internal TransferCheckpointStoreOptions(bool enabled, string localCheckpointerPath) + internal TransferCheckpointStoreOptions(bool enabled, string localCheckpointPath) { Enabled = enabled; - CheckpointerPath = localCheckpointerPath; + CheckpointPath = localCheckpointPath; } } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferItemCompletedEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemCompletedEventArgs.cs index e9d3a4614cfdd..ec1d9575f8be1 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferItemCompletedEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemCompletedEventArgs.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + using System.Threading; -using Azure.Core; using Azure.Storage.Common; namespace Azure.Storage.DataMovement @@ -14,12 +14,12 @@ public class TransferItemCompletedEventArgs : TransferEventArgs /// /// Gets the that was the source resource for the transfer. /// - public StorageResourceItem SourceResource { get; } + public StorageResourceItem Source { get; } /// /// Gets the that was the destination resource for the transfer. /// - public StorageResourceItem DestinationResource { get; } + public StorageResourceItem Destination { get; } /// /// Initializes a new instance of the . @@ -54,8 +54,8 @@ public TransferItemCompletedEventArgs( { Argument.AssertNotNull(sourceResource, nameof(sourceResource)); Argument.AssertNotNull(destinationResource, nameof(destinationResource)); - SourceResource = sourceResource; - DestinationResource = destinationResource; + Source = sourceResource; + Destination = destinationResource; } } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferItemFailedEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemFailedEventArgs.cs index baf08a8a6db01..f1a4bd5a5c0cc 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferItemFailedEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemFailedEventArgs.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + using System; using System.Threading; -using Azure.Core; using Azure.Storage.Common; namespace Azure.Storage.DataMovement @@ -15,12 +15,12 @@ public class TransferItemFailedEventArgs : TransferEventArgs /// /// Gets the that was the source resource for the transfer. /// - public StorageResource SourceResource { get; } + public StorageResource Source { get; } /// /// Gets the that was the destination resource for the transfer. /// - public StorageResource DestinationResource { get; } + public StorageResource Destination { get; } /// /// Gets the that was thrown during the job. @@ -63,8 +63,8 @@ public TransferItemFailedEventArgs( Argument.AssertNotNull(sourceResource, nameof(sourceResource)); Argument.AssertNotNull(destinationResource, nameof(destinationResource)); Argument.AssertNotNull(exception, nameof(exception)); - SourceResource = sourceResource; - DestinationResource = destinationResource; + Source = sourceResource; + Destination = destinationResource; Exception = exception; } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferItemSkippedEventArgs.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemSkippedEventArgs.cs index 609898e858f2c..9e882798bae99 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferItemSkippedEventArgs.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferItemSkippedEventArgs.cs @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; + using System.Threading; -using Azure.Core; using Azure.Storage.Common; namespace Azure.Storage.DataMovement @@ -15,12 +14,12 @@ public class TransferItemSkippedEventArgs : TransferEventArgs /// /// Gets the that was the source resource for the transfer. /// - public StorageResourceItem SourceResource { get; } + public StorageResourceItem Source { get; } /// /// Gets the that was the destination resource for the transfer. /// - public StorageResourceItem DestinationResource { get; } + public StorageResourceItem Destination { get; } /// /// Initializes a new instance of the . @@ -55,8 +54,8 @@ public TransferItemSkippedEventArgs( { Argument.AssertNotNull(sourceResource, nameof(sourceResource)); Argument.AssertNotNull(destinationResource, nameof(destinationResource)); - SourceResource = sourceResource; - DestinationResource = destinationResource; + Source = sourceResource; + Destination = destinationResource; } } } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs index f9bc7bd0bf64d..152ebf4b79c0a 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferJobInternal.cs @@ -91,7 +91,7 @@ internal delegate Task CreateJobPartMultiAsync( /// /// Determines how files are created or if they should be overwritten if they already exists /// - internal StorageResourceCreationPreference _creationPreference; + internal StorageResourceCreationMode _creationPreference; /// /// Event handler for tracking status changes in job parts. @@ -111,7 +111,7 @@ internal delegate Task CreateJobPartMultiAsync( /// /// Number of single transfers skipped during Transfer due to no overwrite allowed as specified in - /// + /// /// public SyncAsyncEventHandler TransferSkippedEventHandler { get; internal set; } @@ -151,7 +151,7 @@ private TransferJobInternal( TransferErrorMode errorHandling, long? initialTransferSize, long? maximumTransferChunkSize, - StorageResourceCreationPreference creationPreference, + StorageResourceCreationMode creationPreference, ArrayPool arrayPool, SyncAsyncEventHandler statusEventHandler, SyncAsyncEventHandler failedEventHandler, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferManager.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferManager.cs index 8068939ed2f8b..9c682b28201b4 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferManager.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferManager.cs @@ -68,9 +68,9 @@ public TransferManager(TransferManagerOptions options = default) readers: options?.MaximumConcurrency ?? DataMovementConstants.Channels.MaxJobChunkReaders, capacity: DataMovementConstants.Channels.JobChunkCapacity), new(ArrayPool.Shared, - options?.ErrorHandling ?? TransferErrorMode.StopOnAnyFailure, + options?.ErrorMode ?? TransferErrorMode.StopOnAnyFailure, new ClientDiagnostics(options?.ClientOptions ?? ClientOptions.Default)), - CheckpointerExtensions.BuildCheckpointer(options?.CheckpointerOptions), + CheckpointerExtensions.BuildCheckpointer(options?.CheckpointStoreOptions), options?.ResumeProviders != null ? new List(options.ResumeProviders) : new(), default) {} @@ -132,13 +132,13 @@ private async Task ProcessPartAsync(JobPartInternal part, CancellationToken canc /// Return true once the transfer has been successfully paused or false if the transfer /// was already completed. /// - public virtual async Task PauseTransferIfRunningAsync(string transferId, CancellationToken cancellationToken = default) + public virtual async Task PauseTransferAsync(string transferId, CancellationToken cancellationToken = default) { cancellationToken = LinkCancellation(cancellationToken); Argument.AssertNotNullOrEmpty(transferId, nameof(transferId)); if (!_transfers.TryGetValue(transferId, out TransferOperation transfer)) { - throw Errors.InvalidTransferId(nameof(PauseTransferIfRunningAsync), transferId); + throw Errors.InvalidTransferId(nameof(PauseTransferAsync), transferId); } await transfer.PauseAsync(cancellationToken: cancellationToken).ConfigureAwait(false); } diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferManagerOptions.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferManagerOptions.cs index 2358471ba6cb7..e393c71812a95 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferManagerOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferManagerOptions.cs @@ -40,7 +40,7 @@ internal class TransferManagerClientOptions : ClientOptions /// Optional. Sets the way errors during a transfer will be handled. /// Default is . /// - public TransferErrorMode ErrorHandling { get; set; } + public TransferErrorMode ErrorMode { get; set; } /// /// The maximum number of workers that may be used in a parallel transfer. @@ -48,10 +48,10 @@ internal class TransferManagerClientOptions : ClientOptions public int? MaximumConcurrency { get; set; } /// - /// Optional. Defines the options for creating a checkpointer which is used for saving + /// Optional. Defines the options for creating a checkpoint which is used for saving /// transfer state so transfers can be resumed. /// - public TransferCheckpointStoreOptions CheckpointerOptions { get; set; } + public TransferCheckpointStoreOptions CheckpointStoreOptions { get; set; } internal TransferManagerClientOptions ClientOptions { get; } = new(); diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferOptions.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferOptions.cs index d127dc9e2219c..2dccd6553e742 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferOptions.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferOptions.cs @@ -93,14 +93,14 @@ public bool Equals(TransferOptions obj) /// Configures the behavior when a transfer encounters a resource that /// already exists. /// - /// Will default to - /// which will be when + /// Will default to + /// which will be when /// starting a new transfer. /// When resuming a transfer, the value will default to the value used when first starting /// the transfer for all resources that were successfully enumerated and the regular default /// for any remaining resources. /// - public StorageResourceCreationPreference CreationPreference { get; set; } + public StorageResourceCreationMode CreationPreference { get; set; } /// /// If the transfer status of the job changes then the event will get added to this handler. diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferState.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferState.cs index 450fa14f605d3..d4913a35f5817 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferState.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferState.cs @@ -28,7 +28,7 @@ public enum TransferState /// /// The transfer is in progress and is in the process of being paused. /// - /// Transfer can be stopped if + /// Transfer can be stopped if /// or is called. /// Pausing = 3, @@ -37,13 +37,13 @@ public enum TransferState /// The transfer is in progress and is in the process of being stopped. /// /// Transfer can be stopped if is - /// enabled in the . + /// enabled in the . /// Stopping = 4, /// /// The transfer has been paused. When transfer is paused - /// (e.g. see ) + /// (e.g. see ) /// during the transfer, this will be the value. /// Paused = 5, diff --git a/sdk/storage/Azure.Storage.DataMovement/src/TransferStatus.cs b/sdk/storage/Azure.Storage.DataMovement/src/TransferStatus.cs index a68f9e0ff2b3b..6ade57dc43c6d 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/TransferStatus.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/TransferStatus.cs @@ -43,7 +43,7 @@ public class TransferStatus : IEquatable /// If set to `false`, the transfer currently has no items that has been skipped. /// /// It's possible to never have any items skipped if - /// is not enabled in the . + /// is not enabled in the . /// public bool HasSkippedItems => _hasSkippedItemValue != 0; diff --git a/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamJobPart.cs b/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamJobPart.cs index cb195bda625cb..7cfe629d1feb0 100644 --- a/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamJobPart.cs +++ b/sdk/storage/Azure.Storage.DataMovement/src/UriToStreamJobPart.cs @@ -91,7 +91,7 @@ private UriToStreamJobPart( TransferStatus jobPartStatus, long initialTransferSize, long transferChunkSize, - StorageResourceCreationPreference createPreference) + StorageResourceCreationMode createPreference) : base(transferOperation: job._transferOperation, partNumber: partNumber, sourceResource: sourceResource, @@ -166,7 +166,7 @@ public static UriToStreamJobPart CreateJobPartFromCheckpoint( TransferStatus jobPartStatus, long initialTransferSize, long transferChunkSize, - StorageResourceCreationPreference createPreference) + StorageResourceCreationMode createPreference) { return new UriToStreamJobPart( job: job, @@ -374,7 +374,7 @@ internal async Task CompleteFileDownload() // Apply necessary transfer completions on the destination. await _destinationResource.CompleteTransferAsync( - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, cancellationToken: _cancellationToken).ConfigureAwait(false); // Dispose the handlers @@ -444,7 +444,7 @@ public async Task CopyToStreamInternal( // TODO: change to custom offset based on chunk offset await _destinationResource.CopyFromStreamAsync( stream: source, - overwrite: _createMode == StorageResourceCreationPreference.OverwriteIfExists, + overwrite: _createMode == StorageResourceCreationMode.OverwriteIfExists, streamLength: sourceLength, completeLength: expectedLength, options: new StorageResourceWriteToOffsetOptions() @@ -456,7 +456,7 @@ await _destinationResource.CopyFromStreamAsync( return true; } catch (IOException ex) - when (_createMode == StorageResourceCreationPreference.SkipIfExists && + when (_createMode == StorageResourceCreationMode.SkipIfExists && ex.Message.Contains("Cannot overwrite file.")) { // Skip file that already exists on the destination. diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/CheckpointerTesting.cs b/sdk/storage/Azure.Storage.DataMovement/tests/CheckpointerTesting.cs index 09572464eb067..17b00c75017c7 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/CheckpointerTesting.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/CheckpointerTesting.cs @@ -21,7 +21,7 @@ internal static class CheckpointerTesting internal const string DefaultDestinationTypeId = "BlockBlob"; internal const string DefaultDestinationPath = "C:/sample-destination"; internal const string DefaultWebDestinationPath = "https://example.com/destination"; - internal const StorageResourceCreationPreference DefaultCreatePreference = StorageResourceCreationPreference.FailIfExists; + internal const StorageResourceCreationMode DefaultCreatePreference = StorageResourceCreationMode.FailIfExists; internal const long DefaultInitialTransferSize = 32 * Constants.MB; internal const long DefaultChunkSize = 4 * Constants.MB; internal const byte DefaultPriority = 0; @@ -42,7 +42,7 @@ internal static JobPartPlanHeader CreateDefaultJobPartHeader( string destinationTypeId = DefaultDestinationTypeId, string sourcePath = DefaultSourcePath, string destinationPath = DefaultDestinationPath, - StorageResourceCreationPreference createPreference = DefaultCreatePreference, + StorageResourceCreationMode createPreference = DefaultCreatePreference, long initialTransferSize = DefaultInitialTransferSize, long chunkSize = DefaultChunkSize, byte priority = DefaultPriority, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/CleanUpTransferTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/CleanUpTransferTests.cs index c72e5d22f814d..b38b23432c773 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/CleanUpTransferTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/CleanUpTransferTests.cs @@ -28,11 +28,12 @@ private Mock GetRemoteSourceResource(long length = Constant mock.Setup(b => b.GetDestinationCheckpointDetails()) .Returns(new MockResourceCheckpointDetails()); mock.Setup(b => b.GetPropertiesAsync(It.IsAny())) - .Returns(Task.FromResult(new StorageResourceItemProperties( - resourceLength: length, - eTag: default, - lastModifiedTime: DateTimeOffset.UtcNow, - properties: default))); + .Returns(Task.FromResult(new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = default, + LastModifiedTime = DateTimeOffset.UtcNow, + })); mock.Setup(b => b.GetCopyAuthorizationHeaderAsync(It.IsAny())) .Returns(Task.FromResult(default)); return mock; diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/CommitChunkHandlerTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/CommitChunkHandlerTests.cs index 754bf58d8b151..66e3f95a96448 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/CommitChunkHandlerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/CommitChunkHandlerTests.cs @@ -545,11 +545,13 @@ public async Task CompleteTransferTask_Properties() { "Metadata", metadata }, { "Tags", tags } }; - StorageResourceItemProperties properties = new( - resourceLength: expectedLength, - eTag: new ETag("etag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties); + StorageResourceItemProperties properties = new() + { + ResourceLength = expectedLength, + ETag = new ETag("etag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + }; var commitBlockHandler = new CommitChunkHandler( expectedLength: expectedLength, blockSize: blockSize, diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/DisabledCheckpointerTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/DisabledCheckpointerTests.cs index 30b595e4a8c99..4919828e3aa9a 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/DisabledCheckpointerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/DisabledCheckpointerTests.cs @@ -20,7 +20,7 @@ public async Task TransferManager_GetTransfers() { TransferManagerOptions managerOptions = new() { - CheckpointerOptions = TransferCheckpointStoreOptions.Disabled() + CheckpointStoreOptions = TransferCheckpointStoreOptions.DisableCheckpoint() }; TransferManager transferManager = new(managerOptions); @@ -36,7 +36,7 @@ public void TransferManager_Resume() { TransferManagerOptions managerOptions = new() { - CheckpointerOptions = TransferCheckpointStoreOptions.Disabled() + CheckpointStoreOptions = TransferCheckpointStoreOptions.DisableCheckpoint() }; TransferManager transferManager = new(managerOptions); @@ -53,7 +53,7 @@ public async Task BasicTransfer_Single( (StorageResourceItem source, StorageResourceItem destination) = MockStorageResourceItem.GetMockTransferResources(transferDirection); TransferManagerOptions managerOptions = new() { - CheckpointerOptions = TransferCheckpointStoreOptions.Disabled() + CheckpointStoreOptions = TransferCheckpointStoreOptions.DisableCheckpoint() }; TransferManager transferManager = new(managerOptions); @@ -97,7 +97,7 @@ public async Task BasicTransfer_Container( TransferManagerOptions managerOptions = new() { - CheckpointerOptions = TransferCheckpointStoreOptions.Disabled() + CheckpointStoreOptions = TransferCheckpointStoreOptions.DisableCheckpoint() }; TransferManager transferManager = new(managerOptions); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/GetTransfersTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/GetTransfersTests.cs index 74c46ca678232..9522472af77f0 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/GetTransfersTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/GetTransfersTests.cs @@ -25,7 +25,7 @@ public class GetTransfersTests private TransferManagerOptions GetDefaultManagerOptions(string checkpointerPath) => new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(checkpointerPath) + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(checkpointerPath) }; private void AssertListTransfersEquals(IList expected, IList actual) @@ -216,7 +216,7 @@ public async Task GetTransfers_LocalCheckpointer() // Build TransferManager with the stored transfers TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(test.DirectoryPath) + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(test.DirectoryPath) }; TransferManager manager = new TransferManager(options); @@ -258,7 +258,7 @@ public async Task GetResumableTransfers_LocalCheckpointer() // Build TransferManager with the stored transfers TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(test.DirectoryPath) + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(test.DirectoryPath) }; TransferManager manager = new TransferManager(options); @@ -297,7 +297,7 @@ public async Task GetResumableTransfers_IgnoresCompleted() // Build TransferManager with the stored transfers TransferManagerOptions options = new TransferManagerOptions() { - CheckpointerOptions = TransferCheckpointStoreOptions.Local(test.DirectoryPath) + CheckpointStoreOptions = TransferCheckpointStoreOptions.CreateLocalStore(test.DirectoryPath) }; TransferManager manager = new TransferManager(options); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/MockStorageResourceItem.cs b/sdk/storage/Azure.Storage.DataMovement/tests/MockStorageResourceItem.cs index f951bfc2d629f..7e9e1197bdc74 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/MockStorageResourceItem.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/MockStorageResourceItem.cs @@ -77,11 +77,12 @@ protected internal override Task DeleteIfExistsAsync(CancellationToken can protected internal override Task GetPropertiesAsync(CancellationToken token = default) { - return Task.FromResult(new StorageResourceItemProperties( - resourceLength: Length ?? 0, - eTag: new ETag("etag"), - lastModifiedTime: DateTimeOffset.UtcNow, - properties: default)); + return Task.FromResult(new StorageResourceItemProperties() + { + ResourceLength = Length ?? 0, + ETag = new ETag("etag"), + LastModifiedTime = DateTimeOffset.UtcNow + }); } protected internal override Task GetCopyAuthorizationHeaderAsync(CancellationToken cancellationToken = default) diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/PauseResumeTransferMockedTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/PauseResumeTransferMockedTests.cs index b421536dcba04..8bfafc192be5b 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/PauseResumeTransferMockedTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/PauseResumeTransferMockedTests.cs @@ -249,7 +249,7 @@ public async Task PauseResumeDuringJobProcessing_ItemTransfer( // Issue Pause for all of the transfers foreach (TransferOperation transfer in transfers) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } @@ -399,7 +399,7 @@ public async Task PauseResumeDuringPartProcessing_ItemTransfer( // Issue Pause for all of the transfers foreach (TransferOperation transfer in transfers) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } @@ -544,7 +544,7 @@ public async Task PauseResumeDuringChunkProcessing_ItemTransfer( // Issue Pause for all of the transfers foreach (TransferOperation transfer in transfers) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); if (pauseLocation == PauseLocation.PauseProcessStart) { Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); @@ -679,7 +679,7 @@ public async Task PauseResumeDuringJobProcessing_ContainerTransfer( // Issue Pause for all of the transfers foreach (TransferOperation transfer in transfers) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } @@ -833,7 +833,7 @@ public async Task PauseResumeDuringPartProcessing_ContainerTransfer( // Issue Pause for all of the transfers foreach (TransferOperation transfer in transfers) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } @@ -979,7 +979,7 @@ public async Task PauseResumeDuringChunkProcessing_ContainerTransfer( // Issue Pause for all transfers foreach (TransferOperation transfer in transfers) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); if (pauseLocation == PauseLocation.PauseProcessStart) { Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); @@ -1111,7 +1111,7 @@ public async Task MultiplePausesAndResumes_ItemTransfer( // Pause transfers #1 foreach (TransferOperation transfer in transfers) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } @@ -1149,7 +1149,7 @@ public async Task MultiplePausesAndResumes_ItemTransfer( // Pause transfers #2 foreach (TransferOperation transfer in resumedTransfers1) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } @@ -1190,7 +1190,7 @@ public async Task MultiplePausesAndResumes_ItemTransfer( // Pause transfers #3 foreach (TransferOperation transfer in resumedTransfers2) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } @@ -1286,7 +1286,7 @@ public async Task MultiplePausesAndResumes_ContainerTransfer( // Pause transfers #1 foreach (TransferOperation transfer in transfers) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } @@ -1324,7 +1324,7 @@ public async Task MultiplePausesAndResumes_ContainerTransfer( // Pause transfers #2 foreach (TransferOperation transfer in resumedTransfers1) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } @@ -1365,7 +1365,7 @@ public async Task MultiplePausesAndResumes_ContainerTransfer( // Pause transfers #3 foreach (TransferOperation transfer in resumedTransfers2) { - Task pauseTask = transferManager.PauseTransferIfRunningAsync(transfer.Id); + Task pauseTask = transferManager.PauseTransferAsync(transfer.Id); Assert.That(TransferState.Pausing, Is.EqualTo(transfer.Status.State), "Error in transitioning to Pausing state"); } diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/ServiceToServiceJobPartTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/ServiceToServiceJobPartTests.cs index 7ee10f380d6ec..259e3ed4d1128 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/ServiceToServiceJobPartTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/ServiceToServiceJobPartTests.cs @@ -54,11 +54,13 @@ private StorageResourceItemProperties GetResourceProperties(int length) { DataMovementConstants.ResourceProperties.Metadata, metadata }, { DataMovementConstants.ResourceProperties.SourceFilePermissionKey, DefaultSourcePermissionKey } }; - return new( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties); + return new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new ETag("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + }; } private Mock GetStorageResourceItem(int length = Constants.KB) diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/MemoryStorageResourceItem.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/MemoryStorageResourceItem.cs index 51b5968847ceb..a8b3502e06294 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/MemoryStorageResourceItem.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/MemoryStorageResourceItem.cs @@ -76,7 +76,12 @@ protected internal override Task GetCopyAuthorizationHeaderAs protected internal override Task GetPropertiesAsync(CancellationToken token = default) { - return Task.FromResult(new StorageResourceItemProperties(Buffer.Length, new ETag("etag"), DateTimeOffset.UtcNow, default)); + return Task.FromResult(new StorageResourceItemProperties() + { + ResourceLength = Buffer.Length, + ETag = new ETag("etag"), + LastModifiedTime = DateTimeOffset.UtcNow + }); } protected internal override StorageResourceCheckpointDetails GetDestinationCheckpointDetails() diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferCopyTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferCopyTestBase.cs index 96f72d3f5a3c2..061b7d8280b0e 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferCopyTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferCopyTestBase.cs @@ -291,7 +291,7 @@ private async Task CopyRemoteObjectsAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; List copyObjectInfo = new List(objectCount); @@ -502,7 +502,7 @@ public async Task SourceObjectToDestinationObject_Overwrite_Exists() // Create options bag to overwrite any existing destination. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, }; List optionsList = new List() { options }; List objectNames = new List() { name }; @@ -530,7 +530,7 @@ public async Task SourceObjectToDestinationObject_Overwrite_NotExists() // Create options bag to overwrite any existing destination. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, }; List optionsList = new List() { options }; @@ -568,7 +568,7 @@ public async Task SourceObjectToDestinationObject_Skip_Exists() // Create options bag to overwrite any existing destination. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists, + CreationPreference = StorageResourceCreationMode.SkipIfExists, }; // Create new source block object. @@ -630,7 +630,7 @@ public async Task SourceObjectToDestinationObject_Failure_Exists() // Create options bag to fail and keep track of the failure. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists, + CreationPreference = StorageResourceCreationMode.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); // Create new source object. @@ -759,7 +759,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists + CreationPreference = StorageResourceCreationMode.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -805,7 +805,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() // Create transfer options with Skipping available TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists + CreationPreference = StorageResourceCreationMode.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryCopyTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryCopyTestBase.cs index f920194d219be..6d911f370d3a8 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryCopyTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryCopyTestBase.cs @@ -242,7 +242,7 @@ private async Task CopyDirectoryAndVerifyAsync( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; // Initialize transferManager @@ -371,7 +371,7 @@ public async Task DirectoryToDirectory_EmptyFolder() TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure, + ErrorMode = TransferErrorMode.ContinueOnFailure, MaximumConcurrency = 1, }; TransferManager transferManager = new TransferManager(managerOptions); @@ -522,7 +522,7 @@ public async Task DirectoryToDirectory_OverwriteExists() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists + CreationPreference = StorageResourceCreationMode.OverwriteIfExists }; // Act @@ -567,7 +567,7 @@ public async Task DirectoryToDirectory_OverwriteNotExists() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists + CreationPreference = StorageResourceCreationMode.OverwriteIfExists }; // Act @@ -728,7 +728,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists + CreationPreference = StorageResourceCreationMode.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -766,7 +766,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() // Create transfer options with Skipping available TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists + CreationPreference = StorageResourceCreationMode.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -803,7 +803,7 @@ public async Task StartTransfer_AwaitCompletion_Failed_SmallChunks() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists, + CreationPreference = StorageResourceCreationMode.FailIfExists, InitialTransferSize = 512, MaximumTransferChunkSize = 512 }; diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryDownloadTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryDownloadTestBase.cs index 85d52912baceb..f2ab84b9ff509 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryDownloadTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDirectoryDownloadTestBase.cs @@ -152,7 +152,7 @@ private async Task DownloadDirectoryAndVerifyAsync( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; StorageResourceContainer sourceResource = GetStorageResourceContainer(sourceContainer, sourcePrefix); @@ -354,7 +354,7 @@ public async Task DownloadDirectoryAsync_SmallChunks_ManyFiles() TransferManagerOptions transferManagerOptions = new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.StopOnAnyFailure, + ErrorMode = TransferErrorMode.StopOnAnyFailure, MaximumConcurrency = 3 }; TransferOptions options = new TransferOptions() @@ -486,7 +486,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists + CreationPreference = StorageResourceCreationMode.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -528,7 +528,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() // Create transfer options with Skipping available TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists + CreationPreference = StorageResourceCreationMode.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -569,7 +569,7 @@ public async Task StartTransfer_AwaitCompletion_Failed_SmallChunks() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists, + CreationPreference = StorageResourceCreationMode.FailIfExists, InitialTransferSize = 512, MaximumTransferChunkSize = 512 }; diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDownloadTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDownloadTestBase.cs index a44a8ec1badb0..8683c88be0f5c 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDownloadTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferDownloadTestBase.cs @@ -195,7 +195,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists + CreationPreference = StorageResourceCreationMode.FailIfExists }; TestEventsRaised testEventRaised = new TestEventsRaised(options); @@ -234,7 +234,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() // Create transfer options with Skipping available TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists + CreationPreference = StorageResourceCreationMode.SkipIfExists }; TestEventsRaised testEventRaised = new TestEventsRaised(options); @@ -324,7 +324,7 @@ private async Task DownloadObjectsAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; List downloadedObjectInfo = new List(objectCount); @@ -429,7 +429,7 @@ public async Task RemoteObjectToLocal_Overwrite_Exists() // Create options bag to overwrite any existing destination. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, }; List optionsList = new List { options }; await DownloadObjectsAndVerify( @@ -451,7 +451,7 @@ public async Task RemoteObjectToLocal_Overwrite_NotExists() // Create options bag to overwrite any existing destination. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, }; List optionsList = new List { options }; await DownloadObjectsAndVerify( @@ -487,12 +487,12 @@ public async Task RemoteObjectToLocal_Skip_Exists() // Create options bag to overwrite any existing destination. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists, + CreationPreference = StorageResourceCreationMode.SkipIfExists, }; options.ItemTransferSkipped += (TransferItemSkippedEventArgs args) => { - if (args.SourceResource != null && - args.DestinationResource != null && + if (args.Source != null && + args.Destination != null && args.TransferId != null) { skippedSeen = true; @@ -548,7 +548,7 @@ public async Task RemoteObjectToLocal_Failure_Exists() // Create options bag to fail and keep track of the failure. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists, + CreationPreference = StorageResourceCreationMode.FailIfExists, }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); StorageResourceItem sourceResource = GetStorageResourceItem(sourceClient); @@ -680,7 +680,7 @@ public async Task RemoteObjectToLocal_SmallConcurrency(int concurrency, int size { TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure, + ErrorMode = TransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -713,7 +713,7 @@ public async Task RemoteObjectToLocal_LargeConcurrency(int concurrency, int size { TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure, + ErrorMode = TransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferUploadDirectoryTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferUploadDirectoryTestBase.cs index 6d613ab482b9d..da1c3f3882a3c 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferUploadDirectoryTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferUploadDirectoryTestBase.cs @@ -144,7 +144,7 @@ private async Task UploadDirectoryAndVerifyAsync( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; StorageResourceContainer sourceResource = LocalResourceProvider.FromDirectory(sourceLocalDirectoryPath); @@ -227,12 +227,12 @@ await SetupDirectoryAsync( TransferOptions options = new() { - CreationPreference = StorageResourceCreationPreference.FailIfExists + CreationPreference = StorageResourceCreationMode.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); TransferManagerOptions transferManagerOptions = new() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; StorageResourceContainer sourceResource = LocalResourceProvider.FromDirectory(disposingLocalDirectory.DirectoryPath); @@ -296,12 +296,12 @@ await SetupDirectoryAsync( TransferOptions options = new() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists + CreationPreference = StorageResourceCreationMode.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); TransferManagerOptions transferManagerOptions = new() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; StorageResourceContainer sourceResource = LocalResourceProvider.FromDirectory(disposingLocalDirectory.DirectoryPath); @@ -345,7 +345,7 @@ public async Task UploadOverwriteIfExists() TransferOptions options = new() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists + CreationPreference = StorageResourceCreationMode.OverwriteIfExists }; CancellationToken cancellationToken = TestHelper.GetTimeoutToken(waitTimeInSec); await InitializeDestinationDataAsync( diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferUploadTestBase.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferUploadTestBase.cs index 7f31bcc9146c4..12474ab91267d 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferUploadTestBase.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/StartTransferUploadTestBase.cs @@ -202,7 +202,7 @@ public async Task StartTransfer_AwaitCompletion_Failed() TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists + CreationPreference = StorageResourceCreationMode.FailIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -249,7 +249,7 @@ public async Task StartTransfer_AwaitCompletion_Skipped() // Create transfer options with Skipping available TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists + CreationPreference = StorageResourceCreationMode.SkipIfExists }; TestEventsRaised testEventsRaised = new TestEventsRaised(options); @@ -338,7 +338,7 @@ private async Task UploadResourceAndVerify( transferManagerOptions ??= new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }; List uploadedObjectInfo = new List(objectCount); @@ -484,7 +484,7 @@ public async Task LocalToRemoteObject_Overwrite_Exists() // Create options bag to overwrite any existing destination. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, }; List optionsList = new List() { options }; List objectNames = new List() { objectName }; @@ -510,7 +510,7 @@ public async Task LocalToRemoteObject_Overwrite_NotExists() // Create options bag to overwrite any existing destination. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.OverwriteIfExists, + CreationPreference = StorageResourceCreationMode.OverwriteIfExists, }; List optionsList = new List() { options }; @@ -548,7 +548,7 @@ public async Task LocalToRemoteObject_Skip_Exists() // Create options bag to overwrite any existing destination. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.SkipIfExists, + CreationPreference = StorageResourceCreationMode.SkipIfExists, }; LocalFilesStorageResourceProvider files = new(); StorageResource sourceResource = files.FromFile(newSourceFile); @@ -607,7 +607,7 @@ public async Task LocalToRemoteObject_Failure_Exists() // Create options bag to fail and keep track of the failure. TransferOptions options = new TransferOptions() { - CreationPreference = StorageResourceCreationPreference.FailIfExists, + CreationPreference = StorageResourceCreationMode.FailIfExists, }; TestEventsRaised testEventRaised = new TestEventsRaised(options); LocalFilesStorageResourceProvider files = new(); @@ -695,7 +695,7 @@ public async Task LocalToRemoteObject_SmallConcurrency(int concurrency, long siz TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure, + ErrorMode = TransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; @@ -729,7 +729,7 @@ public async Task LocalToRemoteObject_LargeConcurrency(int concurrency, int size TransferManagerOptions managerOptions = new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure, + ErrorMode = TransferErrorMode.ContinueOnFailure, MaximumConcurrency = concurrency, }; diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs index e963783e239a3..d75e054a5c6d7 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestEventsRaised.cs @@ -133,8 +133,8 @@ public void AssertUnexpectedFailureCheck() { Assert.Fail( $"Failure occurred at Transfer id: {failure.TransferId}.\n" + - $"Source Resource Path: {failure.SourceResource.Uri.AbsoluteUri}\n" + - $"Destination Resource Path: {failure.DestinationResource.Uri.AbsoluteUri}\n" + + $"Source Resource Path: {failure.Source.Uri.AbsoluteUri}\n" + + $"Destination Resource Path: {failure.Destination.Uri.AbsoluteUri}\n" + $"Exception Message: {failure.Exception.Message}\n" + $"Exception Stack: {failure.Exception.StackTrace}\n"); } @@ -173,8 +173,8 @@ public async Task AssertSingleSkippedCheck() AssertUnexpectedFailureCheck(); Assert.IsEmpty(SingleCompletedEvents); Assert.AreEqual(1, SkippedEvents.Count); - Assert.NotNull(SkippedEvents.First().SourceResource.Uri); - Assert.NotNull(SkippedEvents.First().DestinationResource.Uri); + Assert.NotNull(SkippedEvents.First().Source.Uri); + Assert.NotNull(SkippedEvents.First().Destination.Uri); AssertTransferStatusCollection( new TransferStatus[] { @@ -198,8 +198,8 @@ public async Task AssertSingleFailedCheck(int failureCount) foreach (TransferItemFailedEventArgs args in FailedEvents) { Assert.NotNull(args.Exception); - Assert.NotNull(args.SourceResource.Uri); - Assert.NotNull(args.DestinationResource.Uri); + Assert.NotNull(args.Source.Uri); + Assert.NotNull(args.Destination.Uri); } AssertTransferStatusCollection( diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestTransferWithTimeout.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestTransferWithTimeout.cs index 35ab0d58dd319..f2d30bf78247e 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestTransferWithTimeout.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TestTransferWithTimeout.cs @@ -53,15 +53,15 @@ private static void PrintAllEvents(TestEventsRaised testEventsRaised) { Assert.Fail( $"Skipped event occurred at Transfer id: {skippedEvent.TransferId}.\n" + - $"Source Resource Path: {skippedEvent.SourceResource.Uri.AbsoluteUri}\n" + - $"Destination Resource Path: {skippedEvent.DestinationResource.Uri.AbsoluteUri}\n"); + $"Source Resource Path: {skippedEvent.Source.Uri.AbsoluteUri}\n" + + $"Destination Resource Path: {skippedEvent.Destination.Uri.AbsoluteUri}\n"); } foreach (TransferItemCompletedEventArgs singleCompletedEvent in testEventsRaised.SingleCompletedEvents) { Assert.Fail( $"Single Item Transfer completed occurred at Transfer id: {singleCompletedEvent.TransferId}.\n" + - $"Source Resource Path: {singleCompletedEvent.SourceResource.Uri.AbsoluteUri}\n" + - $"Destination Resource Path: {singleCompletedEvent.DestinationResource.Uri.AbsoluteUri}\n"); + $"Source Resource Path: {singleCompletedEvent.Source.Uri.AbsoluteUri}\n" + + $"Destination Resource Path: {singleCompletedEvent.Destination.Uri.AbsoluteUri}\n"); } foreach (TransferStatusEventArgs statusEvent in testEventsRaised.StatusEvents) { diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TransferManagerFactory.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TransferManagerFactory.cs index e0865acf04ffe..49d13bede24c5 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TransferManagerFactory.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TransferManagerFactory.cs @@ -15,7 +15,7 @@ internal class TransferManagerFactory public TransferManagerFactory(TransferManagerOptions options) { Argument.CheckNotNull(options, nameof(options)); - Argument.CheckNotNull(options.CheckpointerOptions, nameof(options.CheckpointerOptions)); + Argument.CheckNotNull(options.CheckpointStoreOptions, nameof(options.CheckpointStoreOptions)); _options = options; } @@ -24,8 +24,8 @@ public TransferManager BuildTransferManager(List transfers = if (transfers != default) { // populate checkpointer - Argument.AssertNotNullOrWhiteSpace(_options.CheckpointerOptions.CheckpointerPath, nameof(transfers)); - LocalTransferCheckpointerFactory checkpointerFactory = new LocalTransferCheckpointerFactory(_options.CheckpointerOptions.CheckpointerPath); + Argument.AssertNotNullOrWhiteSpace(_options.CheckpointStoreOptions.CheckpointPath, nameof(transfers)); + LocalTransferCheckpointerFactory checkpointerFactory = new LocalTransferCheckpointerFactory(_options.CheckpointStoreOptions.CheckpointPath); checkpointerFactory.BuildCheckpointer(transfers); } TransferManager transferManager = new TransferManager(_options); diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TransferValidator.cs b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TransferValidator.cs index 52bd5cfd2f6b8..927abb08a5de4 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TransferValidator.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/Shared/TransferValidator.cs @@ -23,7 +23,7 @@ public interface IResourceEnumerationItem public TransferManager TransferManager { get; init; } = new(new TransferManagerOptions() { - ErrorHandling = TransferErrorMode.ContinueOnFailure + ErrorMode = TransferErrorMode.ContinueOnFailure }); public async Task TransferAndVerifyAsync( diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/StreamToUriJobPartTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/StreamToUriJobPartTests.cs index 2560c24602d35..6857421d70bd9 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/StreamToUriJobPartTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/StreamToUriJobPartTests.cs @@ -50,11 +50,13 @@ private StorageResourceItemProperties GetResourceProperties(long length) { "Metadata", metadata }, { "Tags", tags } }; - return new( - resourceLength: length, - eTag: new("ETag"), - lastModifiedTime: DateTimeOffset.UtcNow.AddHours(-1), - properties: sourceProperties); + return new StorageResourceItemProperties() + { + ResourceLength = length, + ETag = new("ETag"), + LastModifiedTime = DateTimeOffset.UtcNow.AddHours(-1), + RawProperties = sourceProperties + }; } private Mock GetLocalStorageResourceItem(long length = Constants.KB) diff --git a/sdk/storage/Azure.Storage.DataMovement/tests/TransferManagerTests.cs b/sdk/storage/Azure.Storage.DataMovement/tests/TransferManagerTests.cs index fc0d2b8195e59..8f832671ac62d 100644 --- a/sdk/storage/Azure.Storage.DataMovement/tests/TransferManagerTests.cs +++ b/sdk/storage/Azure.Storage.DataMovement/tests/TransferManagerTests.cs @@ -618,11 +618,10 @@ public static void BasicSetup( .Returns((CancellationToken cancellationToken) => { CancellationHelper.ThrowIfCancellationRequested(cancellationToken); - return Task.FromResult(new StorageResourceItemProperties( - resourceLength: itemSize, - default, - default, - default)); + return Task.FromResult(new StorageResourceItemProperties() + { + ResourceLength = itemSize + }); }); items.Source.Setup(r => r.ReadStreamAsync(It.IsAny(), It.IsAny(), It.IsAny())) @@ -632,7 +631,7 @@ public static void BasicSetup( return Task.FromResult(new StorageResourceReadStreamResult( new Mock().Object, new HttpRange(position, length), - new(itemSize, default, default, new()))); + new() { ResourceLength = itemSize })); }); items.Source.Setup(r => r.IsContainer).Returns(false);