mirror of
https://github.com/Readarr/Readarr.git
synced 2026-03-05 13:20:32 -05:00
Fixed: Validate metadata and quality profiles for root folders
Don't allow `0` as possible value for metadata and quality profiles, and permit to edit root folders with bad values in UI.
This commit is contained in:
@@ -15,18 +15,18 @@ namespace NzbDrone.Core.Books
|
||||
public class BookCutoffService : IBookCutoffService
|
||||
{
|
||||
private readonly IBookRepository _bookRepository;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IQualityProfileService _qualityProfileService;
|
||||
|
||||
public BookCutoffService(IBookRepository bookRepository, IProfileService profileService)
|
||||
public BookCutoffService(IBookRepository bookRepository, IQualityProfileService qualityProfileService)
|
||||
{
|
||||
_bookRepository = bookRepository;
|
||||
_profileService = profileService;
|
||||
_qualityProfileService = qualityProfileService;
|
||||
}
|
||||
|
||||
public PagingSpec<Book> BooksWhereCutoffUnmet(PagingSpec<Book> pagingSpec)
|
||||
{
|
||||
var qualitiesBelowCutoff = new List<QualitiesBelowCutoff>();
|
||||
var profiles = _profileService.All();
|
||||
var profiles = _qualityProfileService.All();
|
||||
|
||||
//Get all items less than the cutoff
|
||||
foreach (var profile in profiles)
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport
|
||||
private readonly IAugmentingService _augmentingService;
|
||||
private readonly IIdentificationService _identificationService;
|
||||
private readonly IRootFolderService _rootFolderService;
|
||||
private readonly IProfileService _qualityProfileService;
|
||||
private readonly IQualityProfileService _qualityProfileService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public ImportDecisionMaker(IEnumerable<IImportDecisionEngineSpecification<LocalBook>> trackSpecifications,
|
||||
@@ -63,7 +63,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport
|
||||
IAugmentingService augmentingService,
|
||||
IIdentificationService identificationService,
|
||||
IRootFolderService rootFolderService,
|
||||
IProfileService qualityProfileService,
|
||||
IQualityProfileService qualityProfileService,
|
||||
Logger logger)
|
||||
{
|
||||
_trackSpecifications = trackSpecifications;
|
||||
|
||||
@@ -13,7 +13,7 @@ using NzbDrone.Core.RootFolders;
|
||||
|
||||
namespace NzbDrone.Core.Profiles.Qualities
|
||||
{
|
||||
public interface IProfileService
|
||||
public interface IQualityProfileService
|
||||
{
|
||||
QualityProfile Add(QualityProfile profile);
|
||||
void Update(QualityProfile profile);
|
||||
@@ -24,7 +24,7 @@ namespace NzbDrone.Core.Profiles.Qualities
|
||||
QualityProfile GetDefaultProfile(string name, Quality cutoff = null, params Quality[] allowed);
|
||||
}
|
||||
|
||||
public class QualityProfileService : IProfileService,
|
||||
public class QualityProfileService : IQualityProfileService,
|
||||
IHandle<ApplicationStartedEvent>,
|
||||
IHandle<CustomFormatAddedEvent>,
|
||||
IHandle<CustomFormatDeletedEvent>
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace NzbDrone.Core.Validation
|
||||
{
|
||||
public class QualityProfileExistsValidator : PropertyValidator
|
||||
{
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IQualityProfileService _qualityProfileService;
|
||||
|
||||
public QualityProfileExistsValidator(IProfileService profileService)
|
||||
public QualityProfileExistsValidator(IQualityProfileService qualityProfileService)
|
||||
{
|
||||
_profileService = profileService;
|
||||
_qualityProfileService = qualityProfileService;
|
||||
}
|
||||
|
||||
protected override string GetDefaultMessageTemplate() => "Quality Profile does not exist";
|
||||
@@ -21,7 +21,7 @@ namespace NzbDrone.Core.Validation
|
||||
return true;
|
||||
}
|
||||
|
||||
return _profileService.Exists((int)context.PropertyValue);
|
||||
return _qualityProfileService.Exists((int)context.PropertyValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace Readarr.Api.V1.Profiles.Quality
|
||||
[V1ApiController]
|
||||
public class QualityProfileController : RestController<QualityProfileResource>
|
||||
{
|
||||
private readonly IProfileService _qualityProfileService;
|
||||
private readonly IQualityProfileService _qualityProfileService;
|
||||
private readonly ICustomFormatService _formatService;
|
||||
|
||||
public QualityProfileController(IProfileService qualityProfileService, ICustomFormatService formatService)
|
||||
public QualityProfileController(IQualityProfileService qualityProfileService, ICustomFormatService formatService)
|
||||
{
|
||||
_qualityProfileService = qualityProfileService;
|
||||
_formatService = formatService;
|
||||
|
||||
@@ -7,17 +7,17 @@ namespace Readarr.Api.V1.Profiles.Quality
|
||||
[V1ApiController("qualityprofile/schema")]
|
||||
public class QualityProfileSchemaController : Controller
|
||||
{
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IQualityProfileService _qualityProfileService;
|
||||
|
||||
public QualityProfileSchemaController(IProfileService profileService)
|
||||
public QualityProfileSchemaController(IQualityProfileService qualityProfileService)
|
||||
{
|
||||
_profileService = profileService;
|
||||
_qualityProfileService = qualityProfileService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public QualityProfileResource GetSchema()
|
||||
{
|
||||
var qualityProfile = _profileService.GetDefaultProfile(string.Empty);
|
||||
var qualityProfile = _qualityProfileService.GetDefaultProfile(string.Empty);
|
||||
|
||||
return qualityProfile.ToResource();
|
||||
}
|
||||
|
||||
@@ -60,10 +60,12 @@ namespace Readarr.Api.V1.RootFolders
|
||||
SharedValidator.RuleFor(c => c.Name)
|
||||
.NotEmpty();
|
||||
|
||||
SharedValidator.RuleFor(c => c.DefaultMetadataProfileId)
|
||||
SharedValidator.RuleFor(c => c.DefaultMetadataProfileId).Cascade(CascadeMode.Stop)
|
||||
.ValidId()
|
||||
.SetValidator(metadataProfileExistsValidator);
|
||||
|
||||
SharedValidator.RuleFor(c => c.DefaultQualityProfileId)
|
||||
SharedValidator.RuleFor(c => c.DefaultQualityProfileId).Cascade(CascadeMode.Stop)
|
||||
.ValidId()
|
||||
.SetValidator(qualityProfileExistsValidator);
|
||||
|
||||
SharedValidator.RuleFor(c => c.Host).ValidHost().When(x => x.IsCalibreLibrary);
|
||||
|
||||
Reference in New Issue
Block a user