Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1115 #1116

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
37 changes: 34 additions & 3 deletions Minio/ApiEndpoints/CompatibilityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,27 @@ public static class CompatibilityExtensions
// Used for backwards compatibility
[Obsolete("Use the ListObjectsEnumAsync instead")]
public static IObservable<Item> ListObjectsAsync(this IBucketOperations self, ListObjectsArgs args)
{
return self.InternalListObjectsAsync(args, CancellationToken.None);
}

// Used for backwards compatibility (with added warning)
[Obsolete("Use the ListObjectsEnumAsync instead (also don't mix cancellation tokens and observables)")]
public static IObservable<Item> ListObjectsAsync(this IBucketOperations self, ListObjectsArgs args,
CancellationToken cancellationToken)
{
return self.InternalListObjectsAsync(args, cancellationToken);
}

private static IObservable<Item> InternalListObjectsAsync(this IBucketOperations self, ListObjectsArgs args,
CancellationToken cancellationToken)
{
return Observable.Create<Item>(async (obs, ct) =>
{
try
{
await foreach (var item in self.ListObjectsEnumAsync(args, ct).ConfigureAwait(false))
using var ctEffective = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, ct);
await foreach (var item in self.ListObjectsEnumAsync(args, ctEffective.Token).ConfigureAwait(false))
obs.OnNext(item);
obs.OnCompleted();
}
Expand All @@ -26,14 +41,30 @@ public static IObservable<Item> ListObjectsAsync(this IBucketOperations self, Li
}

// Used for backwards compatibility
[Obsolete("Use the ListIncompleteUploadsEnumAsync instead")]
[Obsolete("Use the ListObjectsEnumAsync instead")]
public static IObservable<Upload> ListIncompleteUploads(this IObjectOperations self, ListIncompleteUploadsArgs args)
{
return self.InternalListIncompleteUploads(args, CancellationToken.None);
}

// Used for backwards compatibility (with added warning)
[Obsolete("Use the ListIncompleteUploads instead (also don't mix cancellation tokens and observables)")]
public static IObservable<Upload> ListIncompleteUploads(this IObjectOperations self, ListIncompleteUploadsArgs args,
CancellationToken cancellationToken)
{
return self.InternalListIncompleteUploads(args, cancellationToken);
}

private static IObservable<Upload> InternalListIncompleteUploads(this IObjectOperations self,
ListIncompleteUploadsArgs args, CancellationToken cancellationToken = default)
{
return Observable.Create<Upload>(async (obs, ct) =>
{
try
{
await foreach (var item in self.ListIncompleteUploadsEnumAsync(args, ct).ConfigureAwait(false))
using var ctEffective = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, ct);
await foreach (var item in self.ListIncompleteUploadsEnumAsync(args, ctEffective.Token)
.ConfigureAwait(false))
obs.OnNext(item);
obs.OnCompleted();
}
Expand Down
Loading