limit library scan interval (#1073)
* limit library scan interval * fix condition
This commit is contained in:
@@ -11,6 +11,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
### Changed
|
||||
- Upgrade to dotnet 7
|
||||
- Upgrade all docker images to ubuntu jammy and ffmpeg 5.1.2
|
||||
- Limit library scan interval between 0 and 1,000,000
|
||||
- 0 means do not automatically scan libraries
|
||||
- 1 to 999,999 means scan if it has been that many hours since the last scan
|
||||
|
||||
## [0.7.0-beta] - 2022-12-11
|
||||
### Fixed
|
||||
|
||||
@@ -24,8 +24,8 @@ public class UpdateLibraryRefreshIntervalHandler :
|
||||
|
||||
private static Task<Validation<BaseError, Unit>> Validate(UpdateLibraryRefreshInterval request) =>
|
||||
Optional(request.LibraryRefreshInterval)
|
||||
.Where(lri => lri > 0)
|
||||
.Where(lri => lri is >= 0 and < 1_000_000)
|
||||
.Map(_ => Unit.Default)
|
||||
.ToValidation<BaseError>("Tuner count must be greater than zero")
|
||||
.ToValidation<BaseError>("Library refresh interval must be zero or greated")
|
||||
.AsTask();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SynchronizeEmbyLibraryByIdHandler :
|
||||
{
|
||||
var lastScan = new DateTimeOffset(parameters.Library.LastScan ?? SystemTime.MinValueUtc, TimeSpan.Zero);
|
||||
DateTimeOffset nextScan = lastScan + TimeSpan.FromHours(parameters.LibraryRefreshInterval);
|
||||
if (parameters.ForceScan || nextScan < DateTimeOffset.Now)
|
||||
if (parameters.ForceScan || (parameters.LibraryRefreshInterval > 0 && nextScan < DateTimeOffset.Now))
|
||||
{
|
||||
Either<BaseError, Unit> result = parameters.Library.MediaKind switch
|
||||
{
|
||||
@@ -173,7 +173,7 @@ public class SynchronizeEmbyLibraryByIdHandler :
|
||||
|
||||
private Task<Validation<BaseError, int>> ValidateLibraryRefreshInterval() =>
|
||||
_configElementRepository.GetValue<int>(ConfigElementKey.LibraryRefreshInterval)
|
||||
.FilterT(lri => lri > 0)
|
||||
.FilterT(lri => lri is >= 0 and < 1_000_000)
|
||||
.Map(lri => lri.ToValidation<BaseError>("Library refresh interval is invalid"));
|
||||
|
||||
private Task<Validation<BaseError, string>> ValidateFFmpegPath() =>
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SynchronizeJellyfinLibraryByIdHandler :
|
||||
{
|
||||
var lastScan = new DateTimeOffset(parameters.Library.LastScan ?? SystemTime.MinValueUtc, TimeSpan.Zero);
|
||||
DateTimeOffset nextScan = lastScan + TimeSpan.FromHours(parameters.LibraryRefreshInterval);
|
||||
if (parameters.ForceScan || nextScan < DateTimeOffset.Now)
|
||||
if (parameters.ForceScan || (parameters.LibraryRefreshInterval > 0 && nextScan < DateTimeOffset.Now))
|
||||
{
|
||||
Either<BaseError, Unit> result = parameters.Library.MediaKind switch
|
||||
{
|
||||
@@ -173,7 +173,7 @@ public class SynchronizeJellyfinLibraryByIdHandler :
|
||||
|
||||
private Task<Validation<BaseError, int>> ValidateLibraryRefreshInterval() =>
|
||||
_configElementRepository.GetValue<int>(ConfigElementKey.LibraryRefreshInterval)
|
||||
.FilterT(lri => lri > 0)
|
||||
.FilterT(lri => lri is >= 0 and < 1_000_000)
|
||||
.Map(lri => lri.ToValidation<BaseError>("Library refresh interval is invalid"));
|
||||
|
||||
private Task<Validation<BaseError, string>> ValidateFFmpegPath() =>
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ScanLocalLibraryHandler : IRequestHandler<ForceScanLocalLibrary, Ei
|
||||
|
||||
var lastScan = new DateTimeOffset(libraryPath.LastScan ?? SystemTime.MinValueUtc, TimeSpan.Zero);
|
||||
DateTimeOffset nextScan = lastScan + TimeSpan.FromHours(libraryRefreshInterval);
|
||||
if (forceScan || nextScan < DateTimeOffset.Now)
|
||||
if (forceScan || (libraryRefreshInterval > 0 && nextScan < DateTimeOffset.Now))
|
||||
{
|
||||
scanned = true;
|
||||
|
||||
@@ -220,7 +220,7 @@ public class ScanLocalLibraryHandler : IRequestHandler<ForceScanLocalLibrary, Ei
|
||||
|
||||
private Task<Validation<BaseError, int>> ValidateLibraryRefreshInterval() =>
|
||||
_configElementRepository.GetValue<int>(ConfigElementKey.LibraryRefreshInterval)
|
||||
.FilterT(lri => lri > 0)
|
||||
.FilterT(lri => lri is >= 0 and < 1_000_000)
|
||||
.Map(lri => lri.ToValidation<BaseError>("Library refresh interval is invalid"));
|
||||
|
||||
private record RequestParameters(
|
||||
|
||||
@@ -66,7 +66,7 @@ public class
|
||||
{
|
||||
var lastScan = new DateTimeOffset(parameters.Library.LastScan ?? SystemTime.MinValueUtc, TimeSpan.Zero);
|
||||
DateTimeOffset nextScan = lastScan + TimeSpan.FromHours(parameters.LibraryRefreshInterval);
|
||||
if (parameters.ForceScan || nextScan < DateTimeOffset.Now)
|
||||
if (parameters.ForceScan || (parameters.LibraryRefreshInterval > 0 && nextScan < DateTimeOffset.Now))
|
||||
{
|
||||
Either<BaseError, Unit> result = parameters.Library.MediaKind switch
|
||||
{
|
||||
@@ -167,7 +167,7 @@ public class
|
||||
|
||||
private Task<Validation<BaseError, int>> ValidateLibraryRefreshInterval() =>
|
||||
_configElementRepository.GetValue<int>(ConfigElementKey.LibraryRefreshInterval)
|
||||
.FilterT(lri => lri > 0)
|
||||
.FilterT(lri => lri is >= 0 and < 1_000_000)
|
||||
.Map(lri => lri.ToValidation<BaseError>("Library refresh interval is invalid"));
|
||||
|
||||
private Task<Validation<BaseError, string>> ValidateFFmpegPath() =>
|
||||
|
||||
@@ -231,7 +231,7 @@
|
||||
_tunerCount = await _mediator.Send(new GetHDHRTunerCount(), _cts.Token);
|
||||
_hdhrSuccess = string.IsNullOrWhiteSpace(ValidateTunerCount(_tunerCount));
|
||||
_libraryRefreshInterval = await _mediator.Send(new GetLibraryRefreshInterval(), _cts.Token);
|
||||
_scannerSuccess = _libraryRefreshInterval > 0;
|
||||
_scannerSuccess = _libraryRefreshInterval is >= 0 and < 1_000_000;
|
||||
_playoutSettings = await _mediator.Send(new GetPlayoutSettings(), _cts.Token);
|
||||
_playoutSuccess = _playoutSettings.DaysToBuild > 0;
|
||||
_generalSettings = await _mediator.Send(new GetGeneralSettings(), _cts.Token);
|
||||
@@ -241,7 +241,11 @@
|
||||
|
||||
private static string ValidateTunerCount(int tunerCount) => tunerCount <= 0 ? "Tuner count must be greater than zero" : null;
|
||||
|
||||
private static string ValidateLibraryRefreshInterval(int libraryRefreshInterval) => libraryRefreshInterval <= 0 ? "Library refresh interval must be greater than zero" : null;
|
||||
private static string ValidateLibraryRefreshInterval(int libraryRefreshInterval) => libraryRefreshInterval switch {
|
||||
<= -1 => "Library refresh interval must be 0 (do not refresh) or greater than zero",
|
||||
>= 1_000_000 => "Library refresh interval must be less than 1,000,000. Use 0 to disable automatic refresh",
|
||||
_ => null
|
||||
};
|
||||
|
||||
private static string ValidatePlayoutDaysToBuild(int daysToBuild) => daysToBuild <= 0 ? "Days to build must be greater than zero" : null;
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public class SchedulerService : BackgroundService
|
||||
{
|
||||
await DeleteOrphanedArtwork(cancellationToken);
|
||||
await BuildPlayouts(cancellationToken);
|
||||
#if !DEBUG_NO_SYNC
|
||||
#if !DEBUG_NO_SYNC
|
||||
await ScanLocalMediaSources(cancellationToken);
|
||||
await ScanPlexMediaSources(cancellationToken);
|
||||
await ScanJellyfinMediaSources(cancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user