using System.Threading; using System.Threading.Tasks; using Duplicati.Library.Interface; namespace Duplicati.Library.Main.Backend; #nullable enable partial class BackendManager { /// /// Represents a pending QuotaInfo operation /// /// /// Creates a new QuotaInfoOperation /// /// The execution context /// The cancellation token private class QuotaInfoOperation(ExecuteContext context, CancellationToken cancelToken) : PendingOperation(context, true, cancelToken) { /// /// The operation type /// public override BackendActionType Operation => BackendActionType.QuotaInfo; /// /// Executes the operation /// /// The backend to get the quota info from /// The cancellation token /// An awaitable task public override async Task ExecuteAsync(IBackend backend, CancellationToken cancelToken) { IQuotaInfo? quotaInfo = null; if (backend is IQuotaEnabledBackend quotaEnabledBackend && !Context.Options.QuotaDisable) { Context.Statwriter.SendEvent(BackendActionType.QuotaInfo, BackendEventType.Started, null, 0); quotaInfo = await quotaEnabledBackend.GetQuotaInfoAsync(cancelToken).ConfigureAwait(false); } return quotaInfo; } } }