Fixed: Prevent bulk add failure on single validation error for Lists

Fixes #3959
pull/3986/head
Qstick 4 years ago committed by GitHub
parent ae1881a68c
commit eb0bce8dbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test.ImportListTests
Subject.Execute(new ImportListSyncCommand());
Mocker.GetMock<IAddSeriesService>()
.Verify(v => v.AddSeries(It.Is<List<Series>>(t=>t.Count == 0)));
.Verify(v => v.AddSeries(It.Is<List<Series>>(t=>t.Count == 0), It.IsAny<bool>()));
}
[TestCase(MonitorTypes.None, false)]
@ -118,7 +118,7 @@ namespace NzbDrone.Core.Test.ImportListTests
Subject.Execute(new ImportListSyncCommand());
Mocker.GetMock<IAddSeriesService>()
.Verify(v => v.AddSeries(It.Is<List<Series>>(t => t.Count == 1 && t.First().Monitored == expectedSeriesMonitored)));
.Verify(v => v.AddSeries(It.Is<List<Series>>(t => t.Count == 1 && t.First().Monitored == expectedSeriesMonitored), It.IsAny<bool>()));
}
[Test]
@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.ImportListTests
Subject.Execute(new ImportListSyncCommand());
Mocker.GetMock<IAddSeriesService>()
.Verify(v => v.AddSeries(It.Is<List<Series>>(t => t.Count == 0)));
.Verify(v => v.AddSeries(It.Is<List<Series>>(t => t.Count == 0), It.IsAny<bool>()));
}
}
}

@ -136,7 +136,7 @@ namespace NzbDrone.Core.ImportLists
}
}
_addSeriesService.AddSeries(seriesToAdd);
_addSeriesService.AddSeries(seriesToAdd, true);
var message = string.Format("Import List Sync Completed. Items found: {0}, Series added: {1}", reports.Count, seriesToAdd.Count);

@ -16,7 +16,7 @@ namespace NzbDrone.Core.Tv
public interface IAddSeriesService
{
Series AddSeries(Series newSeries);
List<Series> AddSeries(List<Series> newSeries);
List<Series> AddSeries(List<Series> newSeries, bool ignoreErrors = false);
}
public class AddSeriesService : IAddSeriesService
@ -53,19 +53,30 @@ namespace NzbDrone.Core.Tv
return newSeries;
}
public List<Series> AddSeries(List<Series> newSeries)
public List<Series> AddSeries(List<Series> newSeries, bool ignoreErrors = false)
{
var added = DateTime.UtcNow;
var seriesToAdd = new List<Series>();
foreach (var s in newSeries)
{
// TODO: Verify if adding skyhook data will be slow
try
{
var series = AddSkyhookData(s);
series = SetPropertiesAndValidate(series);
series.Added = added;
seriesToAdd.Add(series);
}
catch (ValidationException ex)
{
if (!ignoreErrors)
{
throw;
}
_logger.Debug("tvdbid {0} was not added due to validation failures. {1}", s.TvdbId, ex.Message);
}
}
return _seriesService.AddSeries(seriesToAdd);
}

Loading…
Cancel
Save