From 6a2af13a5cb970babc0d2ec376c14c7f6bedabcd Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Mon, 1 Dec 2025 17:01:52 +0100 Subject: [PATCH] Fixed startup delay not working This PR fixes a race during startup, where it was possible for the scheduler to start before the runner was paused, such that tasks could be started, even if the server was supposed to be paused. This also fixes a more direct issue where the state was not updated during startup, so the UI could look paused, but the runner was active and accepting tasks. This fixes #6634 --- Duplicati/Library/RestAPI/Scheduler.cs | 3 ++- Duplicati/Server/Program.cs | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Duplicati/Library/RestAPI/Scheduler.cs b/Duplicati/Library/RestAPI/Scheduler.cs index 459cc14e4..521849416 100644 --- a/Duplicati/Library/RestAPI/Scheduler.cs +++ b/Duplicati/Library/RestAPI/Scheduler.cs @@ -100,7 +100,6 @@ namespace Duplicati.Server m_updateTasks = new Dictionary>(); m_thread.IsBackground = true; m_thread.Name = "TaskScheduler"; - m_thread.Start(); } public IList> GetProposedSchedule() @@ -121,6 +120,8 @@ namespace Duplicati.Server /// public void Reschedule() { + if (!m_thread.IsAlive && !m_terminate) + m_thread.Start(); m_event.Set(); } diff --git a/Duplicati/Server/Program.cs b/Duplicati/Server/Program.cs index d902ed241..1fdd3df75 100644 --- a/Duplicati/Server/Program.cs +++ b/Duplicati/Server/Program.cs @@ -257,6 +257,14 @@ namespace Duplicati.Server LiveControl.StateChanged = (e) => { LiveControl_StateChanged(queueRunner, connection, eventPollNotify, scheduler, e); }; + // Invoke it once to set initial state + LiveControl_StateChanged(queueRunner, connection, eventPollNotify, scheduler, new LiveControls.LiveControlEvent + { + State = LiveControl.State, + TransfersPaused = LiveControl.TransfersPaused, + WaitTimeExpiration = LiveControl.EstimatedPauseEnd + }); + if (Library.Utility.Utility.ParseBoolOption(commandlineOptions, PING_PONG_KEEPALIVE_OPTION)) { PingPongThread = new Thread(() => PingPongMethod(applicationSettings)) { IsBackground = true };