#nullable enable using Duplicati.Library.IO; using Duplicati.Library.RestAPI; using Duplicati.Library.RestAPI.Abstractions; using Duplicati.Library.Utility; using Duplicati.Server; using Duplicati.WebserverCore.Abstractions; namespace Duplicati.WebserverCore.Services; public class WorkerThreadsManager(ILiveControls liveControls, IScheduler scheduler) : IWorkerThreadsManager { public WorkerThread? WorkerThread { get; private set; } public void Spawn(Action item) { WorkerThread = new WorkerThread(item, liveControls.IsPaused); scheduler.Init(WorkerThread); } public Tuple? CurrentTask { get { var t = WorkerThread?.CurrentTask; return t == null ? null : new Tuple(t.TaskID, t.Backup.ID); } } public void UpdateThrottleSpeeds() { WorkerThread?.CurrentTask?.UpdateThrottleSpeed(); } public long AddTask(Runner.IRunnerData data, bool skipQueue = false) { WorkerThread!.AddTask(data, skipQueue); FIXMEGlobal.StatusEventNotifyer.SignalNewEvent(); return data.TaskID; } }