From f18493d7ee6656d60ed09760e3d1fe63d22c3955 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Thu, 23 Mar 2023 16:35:28 +0100 Subject: [PATCH] adjust download manager initialization and some error logging --- MareSynchronos/MareConfiguration/ConfigurationMigrator.cs | 4 ++-- MareSynchronos/PlayerData/Pairs/CachedPlayer.cs | 6 ++++-- MareSynchronos/WebAPI/Files/FileDownloadManager.cs | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/MareSynchronos/MareConfiguration/ConfigurationMigrator.cs b/MareSynchronos/MareConfiguration/ConfigurationMigrator.cs index 7c3000e..faf7cf0 100644 --- a/MareSynchronos/MareConfiguration/ConfigurationMigrator.cs +++ b/MareSynchronos/MareConfiguration/ConfigurationMigrator.cs @@ -45,7 +45,7 @@ public class ConfigurationMigrator : IHostedService } catch (Exception ex) { - _logger.LogWarning("Failed to migrate, skipping", ex); + _logger.LogWarning(ex, "Failed to migrate, skipping"); } } @@ -66,7 +66,7 @@ public class ConfigurationMigrator : IHostedService } catch (Exception ex) { - _logger.LogWarning("Failed to migrate ServerConfig", ex); + _logger.LogWarning(ex,"Failed to migrate ServerConfig"); } } } diff --git a/MareSynchronos/PlayerData/Pairs/CachedPlayer.cs b/MareSynchronos/PlayerData/Pairs/CachedPlayer.cs index fdeda44..7e3a4c3 100644 --- a/MareSynchronos/PlayerData/Pairs/CachedPlayer.cs +++ b/MareSynchronos/PlayerData/Pairs/CachedPlayer.cs @@ -124,6 +124,8 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase } }); + _downloadManager.Initialize(); + Logger.LogDebug("Initializing Player {obj}", this); } @@ -184,7 +186,7 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase } catch (InvalidOperationException ex) { - Logger.LogWarning("Failed disposing player (not present anymore?)", ex); + Logger.LogWarning(ex, "Failed disposing player (not present anymore?)"); break; } } @@ -459,7 +461,7 @@ public sealed class CachedPlayer : DisposableMediatorSubscriberBase } catch (Exception ex) { - Logger.LogInformation("[{applicationId}] Cancelled, reason: {msg}", _applicationId, ex.Message); + Logger.LogWarning(ex, "[{applicationId}] Cancelled", _applicationId); } }, token); }, downloadToken); diff --git a/MareSynchronos/WebAPI/Files/FileDownloadManager.cs b/MareSynchronos/WebAPI/Files/FileDownloadManager.cs index 5968a26..992ecf0 100644 --- a/MareSynchronos/WebAPI/Files/FileDownloadManager.cs +++ b/MareSynchronos/WebAPI/Files/FileDownloadManager.cs @@ -28,7 +28,10 @@ public partial class FileDownloadManager : DisposableMediatorSubscriberBase _downloadStatus = new Dictionary(StringComparer.Ordinal); _orchestrator = orchestrator; _fileDbManager = fileCacheManager; + } + public void Initialize() + { Mediator.Subscribe(this, (msg) => { if (_downloadReady.ContainsKey(msg.RequestId))