Compare commits

..

1 Commits

Author SHA1 Message Date
Bogdan
7a03a2197b Fixed: Trimming disabled logs database
(cherry picked from commit d5dff8e8d6301b661a713702e1c476705423fc4f)
2024-06-30 17:55:24 +00:00
16 changed files with 42 additions and 44 deletions

View File

@@ -9,7 +9,7 @@ variables:
testsFolder: './_tests'
yarnCacheFolder: $(Pipeline.Workspace)/.yarn
nugetCacheFolder: $(Pipeline.Workspace)/.nuget/packages
majorVersion: '0.3.32'
majorVersion: '0.3.30'
minorVersion: $[counter('minorVersion', 1)]
readarrVersion: '$(majorVersion).$(minorVersion)'
buildName: '$(Build.SourceBranchName).$(readarrVersion)'

View File

@@ -8,7 +8,6 @@ import TagListConnector from 'Components/TagListConnector';
import { createMetadataProfileSelectorForHook } from 'Store/Selectors/createMetadataProfileSelector';
import { createQualityProfileSelectorForHook } from 'Store/Selectors/createQualityProfileSelector';
import { SelectStateInputProps } from 'typings/props';
import translate from 'Utilities/String/translate';
import styles from './ManageImportListsModalRow.css';
interface ManageImportListsModalRowProps {
@@ -71,7 +70,7 @@ function ManageImportListsModalRow(props: ManageImportListsModalRowProps) {
</TableRowCell>
<TableRowCell className={styles.qualityProfileId}>
{qualityProfile?.name ?? translate('None')}
{qualityProfile?.name ?? 'None'}
</TableRowCell>
<TableRowCell className={styles.metadataProfileId}>
@@ -83,7 +82,7 @@ function ManageImportListsModalRow(props: ManageImportListsModalRowProps) {
</TableRowCell>
<TableRowCell className={styles.enableAutomaticAdd}>
{enableAutomaticAdd ? translate('Yes') : translate('No')}
{enableAutomaticAdd ? 'Yes' : 'No'}
</TableRowCell>
<TableRowCell className={styles.tags}>

View File

@@ -75,12 +75,12 @@ class RootFolder extends Component {
{path}
</Label>
<Label kind={qualityProfile?.name ? kinds.SUCCESS : kinds.DANGER}>
{qualityProfile?.name || translate('None')}
<Label kind={kinds.SUCCESS}>
{qualityProfile.name}
</Label>
<Label kind={metadataProfile?.name ? kinds.SUCCESS : kinds.DANGER}>
{metadataProfile?.name || translate('None')}
<Label kind={kinds.SUCCESS}>
{metadataProfile.name}
</Label>
</div>

View File

@@ -46,7 +46,6 @@ namespace NzbDrone.Core.Test.QueueTests
_trackedDownloads = Builder<TrackedDownload>.CreateListOfSize(1)
.All()
.With(v => v.IsTrackable = true)
.With(v => v.DownloadItem = downloadItem)
.With(v => v.RemoteBook = remoteBook)
.Build()

View File

@@ -15,18 +15,18 @@ namespace NzbDrone.Core.Books
public class BookCutoffService : IBookCutoffService
{
private readonly IBookRepository _bookRepository;
private readonly IQualityProfileService _qualityProfileService;
private readonly IProfileService _profileService;
public BookCutoffService(IBookRepository bookRepository, IQualityProfileService qualityProfileService)
public BookCutoffService(IBookRepository bookRepository, IProfileService profileService)
{
_bookRepository = bookRepository;
_qualityProfileService = qualityProfileService;
_profileService = profileService;
}
public PagingSpec<Book> BooksWhereCutoffUnmet(PagingSpec<Book> pagingSpec)
{
var qualitiesBelowCutoff = new List<QualitiesBelowCutoff>();
var profiles = _qualityProfileService.All();
var profiles = _profileService.All();
//Get all items less than the cutoff
foreach (var profile in profiles)

View File

@@ -173,9 +173,6 @@ namespace NzbDrone.Core.Download
.Log();
}
var episodes = _episodeService.GetEpisodes(trackedDownload.RemoteEpisode.Episodes.Select(e => e.Id));
var files = _mediaFileService.GetFiles(episodes.Select(e => e.EpisodeFileId).Where(i => i > 0).Distinct());
trackedDownload.State = TrackedDownloadState.Imported;
var importedAuthorId = historyItems.Where(x => x.EventType == EntityHistoryEventType.BookFileImported)

View File

@@ -1,18 +1,26 @@
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Instrumentation;
namespace NzbDrone.Core.Housekeeping.Housekeepers
{
public class TrimLogDatabase : IHousekeepingTask
{
private readonly ILogRepository _logRepo;
private readonly IConfigFileProvider _configFileProvider;
public TrimLogDatabase(ILogRepository logRepo)
public TrimLogDatabase(ILogRepository logRepo, IConfigFileProvider configFileProvider)
{
_logRepo = logRepo;
_configFileProvider = configFileProvider;
}
public void Clean()
{
if (!_configFileProvider.LogDbEnabled)
{
return;
}
_logRepo.Trim();
}
}

View File

@@ -53,7 +53,7 @@ namespace NzbDrone.Core.MediaFiles.BookImport
private readonly IAugmentingService _augmentingService;
private readonly IIdentificationService _identificationService;
private readonly IRootFolderService _rootFolderService;
private readonly IQualityProfileService _qualityProfileService;
private readonly IProfileService _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,
IQualityProfileService qualityProfileService,
IProfileService qualityProfileService,
Logger logger)
{
_trackSpecifications = trackSpecifications;

View File

@@ -13,7 +13,7 @@ using NzbDrone.Core.RootFolders;
namespace NzbDrone.Core.Profiles.Qualities
{
public interface IQualityProfileService
public interface IProfileService
{
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 : IQualityProfileService,
public class QualityProfileService : IProfileService,
IHandle<ApplicationStartedEvent>,
IHandle<CustomFormatAddedEvent>,
IHandle<CustomFormatDeletedEvent>

View File

@@ -20,7 +20,7 @@ namespace NzbDrone.Core.Queue
public class QueueService : IQueueService, IHandle<TrackedDownloadRefreshedEvent>
{
private readonly IEventAggregator _eventAggregator;
private static List<Queue> _queue = new ();
private static List<Queue> _queue = new List<Queue>();
private readonly IHistoryService _historyService;
public QueueService(IEventAggregator eventAggregator,
@@ -105,11 +105,8 @@ namespace NzbDrone.Core.Queue
public void Handle(TrackedDownloadRefreshedEvent message)
{
_queue = message.TrackedDownloads
.Where(t => t.IsTrackable)
.OrderBy(c => c.DownloadItem.RemainingTime)
.SelectMany(MapQueue)
.ToList();
_queue = message.TrackedDownloads.OrderBy(c => c.DownloadItem.RemainingTime).SelectMany(MapQueue)
.ToList();
_eventAggregator.PublishEvent(new QueueUpdatedEvent());
}

View File

@@ -13,7 +13,7 @@ namespace NzbDrone.Core.RootFolders
public int DefaultQualityProfileId { get; set; }
public MonitorTypes DefaultMonitorOption { get; set; }
public NewItemMonitorTypes DefaultNewItemMonitorOption { get; set; }
public HashSet<int> DefaultTags { get; set; } = new ();
public HashSet<int> DefaultTags { get; set; }
public bool IsCalibreLibrary { get; set; }
public CalibreSettings CalibreSettings { get; set; }

View File

@@ -5,11 +5,11 @@ namespace NzbDrone.Core.Validation
{
public class QualityProfileExistsValidator : PropertyValidator
{
private readonly IQualityProfileService _qualityProfileService;
private readonly IProfileService _profileService;
public QualityProfileExistsValidator(IQualityProfileService qualityProfileService)
public QualityProfileExistsValidator(IProfileService profileService)
{
_qualityProfileService = qualityProfileService;
_profileService = profileService;
}
protected override string GetDefaultMessageTemplate() => "Quality Profile does not exist";
@@ -21,7 +21,7 @@ namespace NzbDrone.Core.Validation
return true;
}
return _qualityProfileService.Exists((int)context.PropertyValue);
return _profileService.Exists((int)context.PropertyValue);
}
}
}

View File

@@ -14,10 +14,10 @@ namespace Readarr.Api.V1.Profiles.Quality
[V1ApiController]
public class QualityProfileController : RestController<QualityProfileResource>
{
private readonly IQualityProfileService _qualityProfileService;
private readonly IProfileService _qualityProfileService;
private readonly ICustomFormatService _formatService;
public QualityProfileController(IQualityProfileService qualityProfileService, ICustomFormatService formatService)
public QualityProfileController(IProfileService qualityProfileService, ICustomFormatService formatService)
{
_qualityProfileService = qualityProfileService;
_formatService = formatService;

View File

@@ -7,17 +7,17 @@ namespace Readarr.Api.V1.Profiles.Quality
[V1ApiController("qualityprofile/schema")]
public class QualityProfileSchemaController : Controller
{
private readonly IQualityProfileService _qualityProfileService;
private readonly IProfileService _profileService;
public QualityProfileSchemaController(IQualityProfileService qualityProfileService)
public QualityProfileSchemaController(IProfileService profileService)
{
_qualityProfileService = qualityProfileService;
_profileService = profileService;
}
[HttpGet]
public QualityProfileResource GetSchema()
{
var qualityProfile = _qualityProfileService.GetDefaultProfile(string.Empty);
var qualityProfile = _profileService.GetDefaultProfile(string.Empty);
return qualityProfile.ToResource();
}

View File

@@ -60,12 +60,10 @@ namespace Readarr.Api.V1.RootFolders
SharedValidator.RuleFor(c => c.Name)
.NotEmpty();
SharedValidator.RuleFor(c => c.DefaultMetadataProfileId).Cascade(CascadeMode.Stop)
.ValidId()
SharedValidator.RuleFor(c => c.DefaultMetadataProfileId)
.SetValidator(metadataProfileExistsValidator);
SharedValidator.RuleFor(c => c.DefaultQualityProfileId).Cascade(CascadeMode.Stop)
.ValidId()
SharedValidator.RuleFor(c => c.DefaultQualityProfileId)
.SetValidator(qualityProfileExistsValidator);
SharedValidator.RuleFor(c => c.Host).ValidHost().When(x => x.IsCalibreLibrary);

View File

@@ -108,7 +108,7 @@ namespace Readarr.Api.V1.RootFolders
DefaultQualityProfileId = resource.DefaultQualityProfileId,
DefaultMonitorOption = resource.DefaultMonitorOption,
DefaultNewItemMonitorOption = resource.DefaultNewItemMonitorOption,
DefaultTags = resource.DefaultTags ?? new HashSet<int>(),
DefaultTags = resource.DefaultTags,
IsCalibreLibrary = resource.IsCalibreLibrary,
CalibreSettings = cs
};