Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Minio.Functional.Tests/FunctionalTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* MinIO .NET Library for Amazon S3 Compatible Cloud Storage,
* (C) 2017-2021 MinIO, Inc.
*
Expand Down Expand Up @@ -364,7 +364,9 @@ internal static async Task BucketExists_Test(IMinioClient minio)

try
{
await minio.RemoveBucketAsync(rbArgs).ConfigureAwait(false);
if (await minio.BucketExistsAsync(beArgs).ConfigureAwait(false))
await minio.RemoveBucketAsync(rbArgs).ConfigureAwait(false);

var found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false);
Assert.IsFalse(found);
await minio.MakeBucketAsync(mbArgs).ConfigureAwait(false);
Expand Down Expand Up @@ -3523,8 +3525,9 @@ internal static async Task PutObject_Test9(IMinioClient minio)
var stream = rsg.GenerateStreamFromSeed(objSize);
var statObj = await PutObject_Tester(minio, bucketName, objectName, null, contentType, 0, null,
stream, progress).ConfigureAwait(false);
Assert.IsTrue(percentage == 100);
Assert.IsTrue(totalBytesTransferred == objSize);
Assert.IsTrue(percentage == 100, "Reported percentage after finished upload was not 100 percent.");
Assert.IsTrue(totalBytesTransferred == objSize,
"Transfered object size does not match with the original object size.");
new MintLogger(nameof(PutObject_Test9), putObjectSignature,
"Tests whether PutObject with progress passes for small object", TestStatus.PASS,
DateTime.Now - startTime,
Expand Down Expand Up @@ -3578,8 +3581,9 @@ internal static async Task PutObject_Test10(IMinioClient minio)
await Setup_Test(minio, bucketName).ConfigureAwait(false);
_ = await PutObject_Tester(minio, bucketName, objectName, null, contentType, 0, null,
rsg.GenerateStreamFromSeed(64 * MB), progress).ConfigureAwait(false);
Assert.IsTrue(percentage == 100);
Assert.IsTrue(totalBytesTransferred == 64 * MB);
Assert.IsTrue(percentage == 100, "Reported percentage after finished upload was not 100 percent.");
Assert.IsTrue(totalBytesTransferred == 64 * MB,
"Transfered object size does not match with the original object size.");
new MintLogger(nameof(PutObject_Test10), putObjectSignature,
"Tests whether multipart PutObject with progress passes", TestStatus.PASS, DateTime.Now - startTime,
args: args).Log();
Expand Down Expand Up @@ -4139,9 +4143,9 @@ internal static async Task CopyObject_Test7(IMinioClient minio)
}
catch (Exception ex)
{
Assert.AreEqual(
Assert.IsTrue(ex.Message.StartsWith(
"MinIO API responded with message=At least one of the pre-conditions you specified did not hold",
ex.Message);
StringComparison.InvariantCulture));
}

new MintLogger("CopyObject_Test7", copyObjectSignature,
Expand Down
11 changes: 6 additions & 5 deletions Minio/RequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
if (request.Method == HttpMethod.Head)
{
if (responseResult.Exception?.GetType().Equals(typeof(BucketNotFoundException)) == true ||
path?.ToList().Count == 1)
path.Length == 1)
responseResult.Exception = new BucketNotFoundException();

if (path?.ToList().Count > 1)
if (path.Length > 1)
{
var found = await minioClient
.BucketExistsAsync(new BucketExistsArgs().WithBucket(path.ToList()[0]), cancellationToken)
Expand All @@ -126,8 +126,6 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
request.Method == HttpMethod.Get)
responseResult.Exception = new MissingObjectLockConfigurationException();
}

return responseResult;
}
catch (Exception ex) when (ex is not (OperationCanceledException or
ObjectNotFoundException))
Expand All @@ -141,6 +139,9 @@ await requestMessageBuilder.ResponseWriter(responseResult.ContentStream, cancell
responseResult = new ResponseResult(request, ex);
return responseResult;
}

minioClient.HandleIfErrorResponse(responseResult, errorHandlers, startTime);
return responseResult;
}

private static Task<ResponseResult> ExecuteWithRetry(this IMinioClient minioClient,
Expand Down Expand Up @@ -369,7 +370,7 @@ private static void HandleIfErrorResponse(this IMinioClient minioClient, Respons
minioClient.LogRequest(response.Request, response, (now - startTime).TotalMilliseconds);
}

if (response.Exception is null)
if (response.Exception is not null)
throw response.Exception;

if (handlers.Any())
Expand Down