Files
duplicati/Duplicati/Library/Main/Backend/BackendManager.ProgressHandler.cs
T

50 lines
1.7 KiB
C#
Raw Normal View History

2025-01-28 08:54:50 +01:00
using Duplicati.Library.Main.Operation.Common;
using Duplicati.Library.Utility;
namespace Duplicati.Library.Main.Backend;
#nullable enable
partial class BackendManager
{
/// <summary>
2025-05-27 12:13:07 +02:00
/// Handles the progress of file transfers for the backend
2025-01-28 08:54:50 +01:00
/// </summary>
2025-04-22 22:54:48 +02:00
private sealed record ProgressHandler(IBackendWriter Stats, ITaskReader TaskReader)
2025-01-28 08:54:50 +01:00
{
2025-04-22 22:54:48 +02:00
/// <summary>
/// Handles the progress of a stream
2025-01-28 08:54:50 +01:00
/// </summary>
/// <param name="pg">The progress</param>
/// <param name="filename">The filename</param>
2025-04-22 22:54:48 +02:00
public void HandleProgress(long pg, string filename)
2025-01-28 08:54:50 +01:00
{
// This pauses and throws on cancellation, but ignores stop
TaskReader.TransferRendevouz().Await();
2025-05-27 12:13:07 +02:00
Stats.BackendProgressUpdater.UpdateProgress(filename, pg);
2025-04-22 22:54:48 +02:00
}
/// <summary>
/// Begins the transfer of a file
/// </summary>
/// <param name="filename">The filename</param>
public void BeginTransfer(BackendActionType type, long size, string filename)
2025-05-27 12:13:07 +02:00
=> Stats.BackendProgressUpdater.StartAction(type, filename, size);
2025-01-28 08:54:50 +01:00
2025-04-22 22:54:48 +02:00
/// <summary>
/// Ends the transfer of a file
/// </summary>
2025-05-27 12:13:07 +02:00
/// <param name="type">The type of action</param>
2025-04-22 22:54:48 +02:00
/// <param name="filename">The filename</param>
2025-05-27 12:13:07 +02:00
public void EndTransfer(BackendActionType type, string filename)
=> Stats.BackendProgressUpdater.EndAction(type, filename);
2025-04-22 22:54:48 +02:00
2025-05-27 12:13:07 +02:00
/// <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);
2025-01-28 08:54:50 +01:00
}
}