mirror of
https://github.com/sphildreth/roadie
synced 2024-11-24 21:23:24 +00:00
Better null handling
This commit is contained in:
parent
4940112b9b
commit
2df0d09326
1 changed files with 14 additions and 1 deletions
|
@ -184,6 +184,10 @@ namespace Roadie.Library.Engines
|
|||
try
|
||||
{
|
||||
var searchName = name.NormalizeName().ToLower();
|
||||
if (string.IsNullOrEmpty(searchName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var searchSortName = !string.IsNullOrEmpty(sortName) ? sortName.NormalizeName().ToLower() : searchName;
|
||||
var specialSearchName = name.ToAlphanumericName();
|
||||
|
||||
|
@ -257,7 +261,7 @@ namespace Roadie.Library.Engines
|
|||
artistName = artistFromJson?.Name;
|
||||
}
|
||||
|
||||
var artist = (await DatabaseQueryForArtistName(artistName).ConfigureAwait(false)).FirstOrDefault();
|
||||
var artist = (await DatabaseQueryForArtistName(artistName).ConfigureAwait(false))?.FirstOrDefault();
|
||||
sw.Stop();
|
||||
if (artist?.IsValid != true)
|
||||
{
|
||||
|
@ -268,6 +272,15 @@ namespace Roadie.Library.Engines
|
|||
if (!string.IsNullOrEmpty(releaseRoadieDataFilename) && File.Exists(releaseRoadieDataFilename))
|
||||
{
|
||||
artist = CacheManager.CacheSerializer.Deserialize<Artist>(File.ReadAllText(releaseRoadieDataFilename));
|
||||
if (!artist.IsValid)
|
||||
{
|
||||
sw.Stop();
|
||||
Logger.LogWarning("Artist data is invalid. Data File [{0}]", releaseRoadieDataFilename);
|
||||
return new OperationResult<Artist>
|
||||
{
|
||||
OperationTime = sw.ElapsedMilliseconds
|
||||
};
|
||||
}
|
||||
var addResult = await Add(artist).ConfigureAwait(false);
|
||||
if (!addResult.IsSuccess)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue