Skip to content

Commit

Permalink
chore: introduces overloads to keep previous signature on CopyGraphOp…
Browse files Browse the repository at this point in the history
…tions

Signed-off-by: Leonardo Chaia <[email protected]>
  • Loading branch information
leonardochaia committed Nov 11, 2024
1 parent 77e8079 commit 06fd442
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/OrasProject.Oras/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static class Extensions
public static Task<Descriptor> CopyAsync(this ITarget src, string srcRef, ITarget dst, string dstRef,
CancellationToken cancellationToken = default)
{
return src.CopyAsync(srcRef, dst, dstRef, copyOptions: new CopyGraphOptions(), cancellationToken);
return src.CopyAsync(srcRef, dst, dstRef, new CopyGraphOptions(), cancellationToken);
}

/// <summary>
Expand All @@ -52,8 +52,8 @@ public static Task<Descriptor> CopyAsync(this ITarget src, string srcRef, ITarge
/// <param name="srcRef"></param>
/// <param name="dst"></param>
/// <param name="dstRef"></param>
/// <param name="cancellationToken"></param>
/// <param name="copyOptions"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public static async Task<Descriptor> CopyAsync(this ITarget src, string srcRef, ITarget dst, string dstRef, CopyGraphOptions? copyOptions = default, CancellationToken cancellationToken = default)
Expand All @@ -63,12 +63,17 @@ public static async Task<Descriptor> CopyAsync(this ITarget src, string srcRef,
dstRef = srcRef;
}
var root = await src.ResolveAsync(srcRef, cancellationToken).ConfigureAwait(false);
await src.CopyGraphAsync(dst, root, cancellationToken, copyOptions).ConfigureAwait(false);
await src.CopyGraphAsync(dst, root, copyOptions, cancellationToken).ConfigureAwait(false);
await dst.TagAsync(root, dstRef, cancellationToken).ConfigureAwait(false);
return root;
}

public static async Task CopyGraphAsync(this ITarget src, ITarget dst, Descriptor node, CancellationToken cancellationToken, CopyGraphOptions? copyOptions = default)
public static Task CopyGraphAsync(this ITarget src, ITarget dst, Descriptor node, CancellationToken cancellationToken = default)
{
return src.CopyGraphAsync(dst, node, new CopyGraphOptions(), cancellationToken);
}

public static async Task CopyGraphAsync(this ITarget src, ITarget dst, Descriptor node, CopyGraphOptions? copyOptions = default, CancellationToken cancellationToken = default)
{
// check if node exists in target
if (await dst.ExistsAsync(node, cancellationToken).ConfigureAwait(false))
Expand All @@ -83,7 +88,7 @@ public static async Task CopyGraphAsync(this ITarget src, ITarget dst, Descripto
// check if the node has successors
foreach (var childNode in successors)
{
await src.CopyGraphAsync(dst, childNode, cancellationToken, copyOptions).ConfigureAwait(false);
await src.CopyGraphAsync(dst, childNode, copyOptions, cancellationToken).ConfigureAwait(false);
}

// perform the copy
Expand Down

0 comments on commit 06fd442

Please sign in to comment.