From 2cacfba81ff2ef65885be07dae113962ea71a6fa Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 18 Mar 2024 16:48:35 -0700 Subject: [PATCH] Fixed: Task progress messages in the UI (cherry picked from commit c6417337812f3578a27f9dc1e44fdad80f557271) --- .../ApplicationIndexerSyncCommand.cs | 2 +- .../IndexerSearch/ReleaseSearchService.cs | 2 +- src/NzbDrone.Core/Messaging/Commands/Command.cs | 2 +- .../ProgressMessaging/ProgressMessageContext.cs | 16 +++++++++++++--- .../Update/Commands/ApplicationUpdateCommand.cs | 2 -- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Core/Applications/ApplicationIndexerSyncCommand.cs b/src/NzbDrone.Core/Applications/ApplicationIndexerSyncCommand.cs index 50318ecbd9e..769843dd367 100644 --- a/src/NzbDrone.Core/Applications/ApplicationIndexerSyncCommand.cs +++ b/src/NzbDrone.Core/Applications/ApplicationIndexerSyncCommand.cs @@ -13,6 +13,6 @@ public ApplicationIndexerSyncCommand() public override bool SendUpdatesToClient => true; - public override string CompletionMessage => null; + public override string CompletionMessage => "Completed"; } } diff --git a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs index 03f546c42b7..e39a2d092a7 100644 --- a/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs +++ b/src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs @@ -196,7 +196,7 @@ private async Task> Dispatch(Func x).ToList(); - _logger.Debug("Total of {0} reports were found for {1} from {2} indexer(s)", reports.Count, criteriaBase, indexers.Count); + _logger.ProgressDebug("Total of {0} reports were found for {1} from {2} indexer(s)", reports.Count, criteriaBase, indexers.Count); return reports; } diff --git a/src/NzbDrone.Core/Messaging/Commands/Command.cs b/src/NzbDrone.Core/Messaging/Commands/Command.cs index 020b5ec64b0..224173437b9 100644 --- a/src/NzbDrone.Core/Messaging/Commands/Command.cs +++ b/src/NzbDrone.Core/Messaging/Commands/Command.cs @@ -23,7 +23,7 @@ public virtual bool SendUpdatesToClient } public virtual bool UpdateScheduledTask => true; - public virtual string CompletionMessage => "Completed"; + public virtual string CompletionMessage => null; public virtual bool RequiresDiskAccess => false; public virtual bool IsExclusive => false; public virtual bool IsTypeExclusive => false; diff --git a/src/NzbDrone.Core/ProgressMessaging/ProgressMessageContext.cs b/src/NzbDrone.Core/ProgressMessaging/ProgressMessageContext.cs index fba9ca3f37c..09fecee2cbf 100644 --- a/src/NzbDrone.Core/ProgressMessaging/ProgressMessageContext.cs +++ b/src/NzbDrone.Core/ProgressMessaging/ProgressMessageContext.cs @@ -1,10 +1,13 @@ -using System; +using System; +using System.Threading; using NzbDrone.Core.Messaging.Commands; namespace NzbDrone.Core.ProgressMessaging { public static class ProgressMessageContext { + private static AsyncLocal _commandModelAsync = new AsyncLocal(); + [ThreadStatic] private static CommandModel _commandModel; @@ -13,8 +16,15 @@ public static class ProgressMessageContext public static CommandModel CommandModel { - get { return _commandModel; } - set { _commandModel = value; } + get + { + return _commandModel ?? _commandModelAsync.Value; + } + set + { + _commandModel = value; + _commandModelAsync.Value = value; + } } public static bool LockReentrancy() diff --git a/src/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs b/src/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs index 0ca1d807439..59a827a0b01 100644 --- a/src/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs +++ b/src/NzbDrone.Core/Update/Commands/ApplicationUpdateCommand.cs @@ -6,7 +6,5 @@ public class ApplicationUpdateCommand : Command { public override bool SendUpdatesToClient => true; public override bool IsExclusive => true; - - public override string CompletionMessage => null; } }