Files
duplicati/Duplicati/Library/Main/Backend/BackendManager.ProgressHandler.cs
T
Kenneth Skovhede 179d1ceb47 Make controller Async
This PR has a large blast radius because it takes the final step and bumps up the Controller to be fully async.

We have historically done a piece-by-piece update, so all operations were already async but the controller interface was kept synchronous.

With this update, the controller is now fully async and all tests are updated.

Most places where the new C# compiler warns about function names not ending in `Async` were also adressed, giving a massive refactor change.

Functionally, no changes are done.
2026-05-13 15:04:13 +02:00

50 lines
1.8 KiB
C#

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