using Duplicati.Library.Main.Operation.Common;
using Duplicati.Library.Utility;
namespace Duplicati.Library.Main.Backend;
#nullable enable
partial class BackendManager
{
///
/// Handles the progress of file transfers for the backend
///
private sealed record ProgressHandler(IBackendWriter Stats, ITaskReader TaskReader)
{
///
/// Handles the progress of a stream
///
/// The progress
/// The filename
public void HandleProgress(long pg, string filename)
{
// This pauses and throws on cancellation, but ignores stop
TaskReader.TransferRendevouz().Await();
Stats.BackendProgressUpdater.UpdateProgress(filename, pg);
}
///
/// Begins the transfer of a file
///
/// The filename
public void BeginTransfer(BackendActionType type, long size, string filename)
=> Stats.BackendProgressUpdater.StartAction(type, filename, size);
///
/// Ends the transfer of a file
///
/// The type of action
/// The filename
public void EndTransfer(BackendActionType type, string filename)
=> Stats.BackendProgressUpdater.EndAction(type, filename);
///
/// Sets whether the backend is blocking
///
/// True if blocking, false otherwise
public void SetIsBlocking(bool blocking)
=> Stats.BackendProgressUpdater.SetBlocking(blocking);
}
}