Skip to content

Commit d843d7d

Browse files
authored
Updated DataLakeFileClient.Upload docs to define overwrite expectations; Removed Magic string PathAlreadyExists (Azure#24984)
1 parent 00af10f commit d843d7d

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

sdk/storage/Azure.Storage.Common/src/Shared/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ internal static class DataLake
334334
public const string AlreadyExists = "ContainerAlreadyExists";
335335
public const string FilesystemNotFound = "FilesystemNotFound";
336336
public const string PathNotFound = "PathNotFound";
337+
public const string PathAlreadyExists = "PathAlreadyExists";
337338

338339
/// <summary>
339340
/// Default concurrent transfers count.

sdk/storage/Azure.Storage.Files.DataLake/src/DataLakeFileClient.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3287,6 +3287,11 @@ public virtual Response<PathInfo> Upload(
32873287
/// The <see cref="Upload(Stream, bool, CancellationToken)"/>
32883288
/// operation creates and uploads content to a file.
32893289
///
3290+
/// If the file already exists, then its content will not be overwritten.
3291+
/// The request will be sent with If-None-Match Header with the value of
3292+
/// the special wildcard. So if the file already exists a
3293+
/// <see cref="RequestFailedException"/> is expected to be thrown.
3294+
///
32903295
/// For more information, see
32913296
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" >
32923297
/// Update Path</see>.
@@ -3314,6 +3319,12 @@ public virtual Response<PathInfo> Upload(
33143319
/// The <see cref="Upload(Stream, bool, CancellationToken)"/>
33153320
/// operation creates and uploads content to a file.
33163321
///
3322+
/// If the overwrite parameter is not specified and
3323+
/// the file already exists, then its content will not be overwritten.
3324+
/// The request will be sent with If-None-Match Header with the value of
3325+
/// the special wildcard. So if the file already exists a
3326+
/// <see cref="RequestFailedException"/> is expected to be thrown.
3327+
///
33173328
/// For more information, see
33183329
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" >
33193330
/// Update Path</see>.
@@ -3349,7 +3360,7 @@ public virtual Response<PathInfo> Upload(
33493360

33503361
/// <summary>
33513362
/// The <see cref="UploadAsync(Stream, DataLakeFileUploadOptions, CancellationToken)"/>
3352-
/// operation creates and uploads content to a file.If the file already exists, its content will be overwritten,
3363+
/// operation creates and uploads content to a file. If the file already exists, its content will be overwritten,
33533364
/// unless otherwise specified in the <see cref="DataLakeFileUploadOptions.Conditions"/> or alternatively use
33543365
/// <see cref="UploadAsync(Stream)"/>, <see cref="UploadAsync(Stream, bool, CancellationToken)"/>.
33553366
///
@@ -3449,6 +3460,11 @@ public virtual Task<Response<PathInfo>> UploadAsync(
34493460
/// The <see cref="UploadAsync(Stream, bool, CancellationToken)"/>
34503461
/// operation creates and uploads content to a file.
34513462
///
3463+
/// If the file already exists, then its content will not be overwritten.
3464+
/// The request will be sent with If-None-Match Header with the value of
3465+
/// the special wildcard. So if the file already exists a
3466+
/// <see cref="RequestFailedException"/> is expected to be thrown.
3467+
///
34523468
/// For more information, see
34533469
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" >
34543470
/// Update Path</see>.
@@ -3477,6 +3493,12 @@ public virtual Task<Response<PathInfo>> UploadAsync(
34773493
/// The <see cref="UploadAsync(Stream, bool, CancellationToken)"/>
34783494
/// operation creates and uploads content to a file.
34793495
///
3496+
/// If the overwrite parameter is not specified and
3497+
/// the file already exists, then its content will not be overwritten.
3498+
/// The request will be sent with If-None-Match Header with the value of
3499+
/// the special wildcard. So if the file already exists a
3500+
/// <see cref="RequestFailedException"/> is expected to be thrown.
3501+
///
34803502
/// For more information, see
34813503
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" >
34823504
/// Update Path</see>.
@@ -3620,6 +3642,11 @@ public virtual Response<PathInfo> Upload(
36203642
/// The <see cref="Upload(Stream, bool, CancellationToken)"/>
36213643
/// operation creates and uploads content to a file.
36223644
///
3645+
/// If the file already exists, then its content will not be overwritten.
3646+
/// The request will be sent with If-None-Match Header with the value of
3647+
/// the special wildcard. So if the file already exists a
3648+
/// <see cref="RequestFailedException"/> is expected to be thrown.
3649+
///
36233650
/// For more information, see
36243651
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" >
36253652
/// Update Path</see>.
@@ -3648,6 +3675,12 @@ public virtual Response<PathInfo> Upload(
36483675
/// The <see cref="Upload(Stream, bool, CancellationToken)"/>
36493676
/// operation creates and uploads content to a file.
36503677
///
3678+
/// If the overwrite parameter is not specified and
3679+
/// the file already exists, then its content will not be overwritten.
3680+
/// The request will be sent with If-None-Match Header with the value of
3681+
/// the special wildcard. So if the file already exists a
3682+
/// <see cref="RequestFailedException"/> is expected to be thrown.
3683+
///
36513684
/// For more information, see
36523685
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" >
36533686
/// Update Path</see>.
@@ -3789,6 +3822,11 @@ public virtual async Task<Response<PathInfo>> UploadAsync(
37893822
/// The <see cref="UploadAsync(Stream, bool, CancellationToken)"/>
37903823
/// operation creates and uploads content to a file.
37913824
///
3825+
/// If the file already exists, then its content will not be overwritten.
3826+
/// The request will be sent with If-None-Match Header with the value of
3827+
/// the special wildcard. So if the file already exists a
3828+
/// <see cref="RequestFailedException"/> is expected to be thrown.
3829+
///
37923830
/// For more information, see
37933831
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" >
37943832
/// Update Path</see>.
@@ -3817,6 +3855,12 @@ await UploadAsync(
38173855
/// The <see cref="UploadAsync(Stream, bool, CancellationToken)"/>
38183856
/// operation creates and uploads content to a file.
38193857
///
3858+
/// If the overwrite parameter is not specified and
3859+
/// the file already exists, then its content will not be overwritten.
3860+
/// The request will be sent with If-None-Match Header with the value of
3861+
/// the special wildcard. So if the file already exists a
3862+
/// <see cref="RequestFailedException"/> is expected to be thrown.
3863+
///
38203864
/// For more information, see
38213865
/// <see href="https://docs.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/update" >
38223866
/// Update Path</see>.

sdk/storage/Azure.Storage.Files.DataLake/src/DataLakePathClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ private async Task<Response<PathInfo>> CreateIfNotExistsInternal(
11531153
cancellationToken).ConfigureAwait(false);
11541154
}
11551155
catch (RequestFailedException storageRequestFailedException)
1156-
when (storageRequestFailedException.ErrorCode == "PathAlreadyExists")
1156+
when (storageRequestFailedException.ErrorCode == Constants.DataLake.PathAlreadyExists)
11571157
{
11581158
response = default;
11591159
}

0 commit comments

Comments
 (0)