mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
cleaned up handling of Unknown quality type.
This commit is contained in:
parent
3c53e6009d
commit
c1bbd0bd5d
@ -28,14 +28,14 @@ public static class ValueInjectorExtensions
|
|||||||
|
|
||||||
foreach (var sourceItem in (IEnumerable)source)
|
foreach (var sourceItem in (IEnumerable)source)
|
||||||
{
|
{
|
||||||
var e = Activator.CreateInstance(listSubType).InjectFrom(sourceItem);
|
var e = Activator.CreateInstance(listSubType).InjectFrom<CloneInjection>(sourceItem);
|
||||||
addMethod.Invoke(result, new[] { e });
|
addMethod.Invoke(result, new[] { e });
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TTarget)new TTarget().InjectFrom(source);
|
return (TTarget)new TTarget().InjectFrom<CloneInjection>(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,6 @@ namespace NzbDrone.Api.Qualities
|
|||||||
{
|
{
|
||||||
public class QualityProfileResource : RestResource
|
public class QualityProfileResource : RestResource
|
||||||
{
|
{
|
||||||
public Int32 Id { get; set; }
|
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
public QualityResource Cutoff { get; set; }
|
public QualityResource Cutoff { get; set; }
|
||||||
public List<QualityResource> Qualities { get; set; }
|
public List<QualityResource> Qualities { get; set; }
|
||||||
@ -15,7 +14,6 @@ public class QualityProfileResource : RestResource
|
|||||||
|
|
||||||
public class QualityResource : RestResource
|
public class QualityResource : RestResource
|
||||||
{
|
{
|
||||||
public Int32 Id { get; set; }
|
|
||||||
public Int32 Weight { get; set; }
|
public Int32 Weight { get; set; }
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public void Init_should_add_all_sizes()
|
|||||||
Subject.Handle(new ApplicationStartedEvent());
|
Subject.Handle(new ApplicationStartedEvent());
|
||||||
|
|
||||||
Mocker.GetMock<IQualitySizeRepository>()
|
Mocker.GetMock<IQualitySizeRepository>()
|
||||||
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 1));
|
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -33,7 +33,7 @@ public void Init_should_insert_any_missing_sizes()
|
|||||||
Subject.Handle(new ApplicationStartedEvent());
|
Subject.Handle(new ApplicationStartedEvent());
|
||||||
|
|
||||||
Mocker.GetMock<IQualitySizeRepository>()
|
Mocker.GetMock<IQualitySizeRepository>()
|
||||||
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 2));
|
.Verify(v => v.Insert(It.IsAny<QualitySize>()), Times.Exactly(Quality.All().Count - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -152,7 +152,6 @@ public static List<Quality> All()
|
|||||||
{
|
{
|
||||||
return new List<Quality>
|
return new List<Quality>
|
||||||
{
|
{
|
||||||
Unknown,
|
|
||||||
SDTV,
|
SDTV,
|
||||||
WEBDL480p,
|
WEBDL480p,
|
||||||
DVD,
|
DVD,
|
||||||
@ -168,6 +167,8 @@ public static List<Quality> All()
|
|||||||
|
|
||||||
public static Quality FindById(int id)
|
public static Quality FindById(int id)
|
||||||
{
|
{
|
||||||
|
if (id == 0) return Unknown;
|
||||||
|
|
||||||
var quality = All().SingleOrDefault(q => q.Id == id);
|
var quality = All().SingleOrDefault(q => q.Id == id);
|
||||||
|
|
||||||
if (quality == null)
|
if (quality == null)
|
||||||
|
@ -45,18 +45,13 @@ public virtual QualitySize Get(int qualityId)
|
|||||||
return _qualitySizeRepository.GetByQualityId(qualityId);
|
return _qualitySizeRepository.GetByQualityId(qualityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Handle(ApplicationStartedEvent message)
|
public void Handle(ApplicationStartedEvent message)
|
||||||
{
|
{
|
||||||
var existing = All();
|
var existing = All();
|
||||||
|
|
||||||
_logger.Debug("Setting up default quality sizes");
|
_logger.Debug("Setting up default quality sizes");
|
||||||
|
|
||||||
foreach (var quality in Quality.All().Where(q => q.Id > 0))
|
foreach (var quality in Quality.All())
|
||||||
{
|
{
|
||||||
if (!existing.Any(s => s.QualityId == quality.Id))
|
if (!existing.Any(s => s.QualityId == quality.Id))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user