adding explicit handling for null item in watcher, skipping user watchers without spotify link, fixed weird systemd issue with async run

This commit is contained in:
andy 2021-12-15 22:04:41 +00:00
parent a0090470e8
commit 46b7cb37bd
3 changed files with 12 additions and 3 deletions

View File

@ -83,7 +83,9 @@ namespace Selector.CLI
var indices = new HashSet<string>();
foreach (var dbWatcher in db.Watcher.Include(w => w.User))
foreach (var dbWatcher in db.Watcher
.Include(w => w.User)
.Where(w => !string.IsNullOrWhiteSpace(w.User.SpotifyRefreshToken)))
{
Logger.LogInformation($"Creating new [{dbWatcher.Type}] watcher");

View File

@ -26,8 +26,7 @@ namespace Selector.CLI
}
};
var host = CreateHostBuilder(args, ConfigureDefault, ConfigureDefaultNlog);
await host.RunConsoleAsync();
CreateHostBuilder(args, ConfigureDefault, ConfigureDefaultNlog).Build().Run();
}
public static RootOptions ConfigureOptions(HostBuilderContext context, IServiceCollection services)

View File

@ -130,6 +130,14 @@ namespace Selector
OnItemChange(GetEvent());
}
}
else if (Previous.Item is null)
{
Logger.LogWarning($"Previous item was null [{Previous.DisplayString()}]");
}
else if (Live.Item is null)
{
Logger.LogWarning($"Live item was null [{Live.DisplayString()}]");
}
else {
Logger.LogError($"Unknown combination of previous and current playing contexts, [{Previous.DisplayString()}] [{Live.DisplayString()}]");
throw new NotSupportedException("Unknown item combination");