Skip to content

Commit

Permalink
Adds missing review comment resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ersan Bozduman committed May 6, 2024
1 parent f82c99c commit e3d9f97
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
10 changes: 6 additions & 4 deletions Minio.Examples/Cases/ListObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Minio.Examples.Cases;
internal static class ListObjects
{
// List objects matching optional prefix in a specified bucket.
public static void Run(IMinioClient minio,
public static async Task RunAsync(IMinioClient minio,
string bucketName = "my-bucket-name",
string prefix = null,
bool recursive = true,
Expand All @@ -38,10 +38,12 @@ public static void Run(IMinioClient minio,
.WithVersions(versions)
.WithUserMetadata(includeUserMetadata);
var observable = minio.ListObjectsAsync(listArgs);
var subscription = observable.Subscribe(
var tcs = new TaskCompletionSource(observable);
using var subscription = observable.Subscribe(
item => Console.WriteLine($"Object: {item.Key}, content-type: {item.UserMetadata.ToList()[0].Value}"),
ex => Console.WriteLine($"OnError: {ex}"),
() => Console.WriteLine($"Listed all objects in bucket {bucketName}\n"));
tcs.SetException,
tcs.SetResult);
await tcs.Task.ConfigureAwait(false);
}
catch (Exception e)
{
Expand Down
13 changes: 7 additions & 6 deletions Minio.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ public static async Task Main()
var lockBucketName = GetRandomName();
var progress = new Progress<ProgressReport>(progressReport =>
{
Console.WriteLine(
$"Percentage: {progressReport.Percentage}% TotalBytesTransferred: {progressReport.TotalBytesTransferred} bytes");
if (progressReport.Percentage != 100)
Console.SetCursorPosition(0, Console.CursorTop - 1);
else Console.WriteLine();
// Console.WriteLine(
// $"Percentage: {progressReport.Percentage}% TotalBytesTransferred: {progressReport.TotalBytesTransferred} bytes");
// if (progressReport.Percentage != 100)
// Console.SetCursorPosition(0, Console.CursorTop - 1);
// else Console.WriteLine();
});
var objectsList = new List<string>();
for (var i = 0; i < 10; i++) objectsList.Add(objectName + i);
Expand Down Expand Up @@ -158,7 +158,8 @@ public static async Task Main()
await StatObject.Run(minioClient, bucketName, objectName).ConfigureAwait(false);

// List the objects in the new bucket
ListObjects.Run(minioClient, bucketName, includeUserMetadata: true);
await ListObjects.RunAsync(minioClient, bucketName, versions: true, includeUserMetadata: true)
.ConfigureAwait(false);

// Get the file and Download the object as file
await GetObject.Run(minioClient, bucketName, objectName, smallFileName).ConfigureAwait(false);
Expand Down
8 changes: 5 additions & 3 deletions Minio/ApiEndpoints/BucketOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public IObservable<Item> ListObjectsAsync(ListObjectsArgs args, CancellationToke
if (args.Versions)
{
var objectList = await GetObjectVersionsListAsync(goArgs, cts.Token).ConfigureAwait(false);
if (objectList is null) return;
// Add user metadata information
if (goArgs.IncludeUserMetadata)
{
Expand Down Expand Up @@ -263,9 +264,10 @@ public IObservable<Item> ListObjectsAsync(ListObjectsArgs args, CancellationToke
else
{
var objectList = await GetObjectListAsync(goArgs, cts.Token).ConfigureAwait(false);
if (objectList.Item2.Count == 0 &&
objectList.Item1.KeyCount.Equals("0", StringComparison.Ordinal) &&
count == 0)
if (objectList is null ||
(objectList.Item2.Count == 0 &&
objectList.Item1.KeyCount.Equals("0", StringComparison.Ordinal) &&
count == 0))
return;
// Add user metadata information
Expand Down
2 changes: 2 additions & 0 deletions Minio/DataModel/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ public DateTime? LastModifiedDateTime
}

[XmlElement] public List<MetadataItem> UserMetadata { get; set; }

[XmlIgnore] public bool UserMetadataSpecified => UserMetadata?.Count < 1;
}

0 comments on commit e3d9f97

Please sign in to comment.