Do not import orphaned episodes (#553)

This commit is contained in:
MBucari 2023-03-27 18:57:41 -06:00
parent add31024da
commit ec9356b36e
2 changed files with 8 additions and 3 deletions

View File

@ -282,7 +282,8 @@ namespace ApplicationServices
catch(ImportValidationException ex) catch(ImportValidationException ex)
{ {
await logDtoItemsAsync(ex.Items, ex.InnerExceptions.ToArray()); await logDtoItemsAsync(ex.Items, ex.InnerExceptions.ToArray());
throw; //If ImportValidationException is thrown, all Dto items get logged as part of the exception
throw new AggregateException(ex.InnerExceptions);
} }
async Task logDtoItemsAsync(IEnumerable<AudibleApi.Common.Item> dtoItems, IEnumerable<Exception> exceptions = null) async Task logDtoItemsAsync(IEnumerable<AudibleApi.Common.Item> dtoItems, IEnumerable<Exception> exceptions = null)

View File

@ -152,13 +152,17 @@ namespace AudibleUtilities
SetSeries(parent, children); SetSeries(parent, children);
} }
int orphansRemoved = items.RemoveAll(i => (i.IsEpisodes || i.IsSeriesParent) && i.Series is null);
if (orphansRemoved > 0)
Serilog.Log.Debug("{orphansRemoved} podcast orphans not imported", orphansRemoved);
sw.Stop(); sw.Stop();
totalTime += sw.Elapsed; totalTime += sw.Elapsed;
Serilog.Log.Logger.Information("Completed indexing series episodes after {elappsed_ms} ms.", sw.ElapsedMilliseconds); Serilog.Log.Logger.Information("Completed indexing series episodes after {elappsed_ms} ms.", sw.ElapsedMilliseconds);
Serilog.Log.Logger.Information($"Completed library scan in {totalTime.TotalMilliseconds:F0} ms."); Serilog.Log.Logger.Information($"Completed library scan in {totalTime.TotalMilliseconds:F0} ms.");
var allExceptions = IValidator.GetAllValidators().SelectMany(v => v.Validate(items)); var allExceptions = IValidator.GetAllValidators().SelectMany(v => v.Validate(items)).ToList();
if (allExceptions?.Any() is true) if (allExceptions?.Count > 0)
throw new ImportValidationException(items, allExceptions); throw new ImportValidationException(items, allExceptions);
return items; return items;