/// <summary> /// Restore files from trash /// </summary> public static async Task RestoreFromTrashAndWaitAsyncAsync([NotNull] this ICommandsClient client, [NotNull] RestoreFromTrashRequest request, CancellationToken cancellationToken = default(CancellationToken), TimeSpan?pullPeriod = null) { var link = await client.RestoreFromTrashAsync(request, cancellationToken).ConfigureAwait(false); if (link.HttpStatusCode == HttpStatusCode.Accepted) { await client.WaitOperationAsync(link, cancellationToken, pullPeriod).ConfigureAwait(false); } }
private static async Task WaitOperationAsync([NotNull] this ICommandsClient client, [NotNull] Link operationLink, CancellationToken cancellationToken, TimeSpan?pullPeriod) { if (pullPeriod == null) { pullPeriod = DefaultPullPeriod; } Operation operation; do { Thread.Sleep(pullPeriod.Value); operation = await client.GetOperationStatus(operationLink, cancellationToken).ConfigureAwait(false); } while (operation.Status == OperationStatus.InProgress && !cancellationToken.IsCancellationRequested); }
public static Task EmptyTrashAndWaitAsyncAsync([NotNull] this ICommandsClient client, [NotNull] string path, CancellationToken cancellationToken, int pullPeriod) { return(EmptyTrashAndWaitAsyncAsync(client, path, cancellationToken, TimeSpan.FromSeconds(pullPeriod))); }
public static Task RestoreFromTrashAndWaitAsyncAsync([NotNull] this ICommandsClient client, [NotNull] RestoreFromTrashRequest request, CancellationToken cancellationToken, int pullPeriod) { return(RestoreFromTrashAndWaitAsyncAsync(client, request, cancellationToken, TimeSpan.FromSeconds(pullPeriod))); }
public static Task DeleteAndWaitAsync([NotNull] this ICommandsClient client, [NotNull] DeleteFileRequest request, CancellationToken cancellationToken, int pullPeriod) { return(DeleteAndWaitAsync(client, request, cancellationToken, TimeSpan.FromSeconds(pullPeriod))); }