scanning and poster improvements (#24)
* first pass at refresh-all-metadata by source * add version to startup logs * lock media source during refresh * fix local media source "name" in collection editor * optimize scanning so playouts only rebuild when necessary * support more poster file types * more scanning improvements; check for missing posters during scans
This commit is contained in:
@@ -6,6 +6,8 @@ using System.Threading.Tasks;
|
||||
using ErsatzTV.Application;
|
||||
using ErsatzTV.Application.MediaSources.Commands;
|
||||
using ErsatzTV.Application.Playouts.Commands;
|
||||
using ErsatzTV.Core.Interfaces.Locking;
|
||||
using ErsatzTV.Core.Metadata;
|
||||
using ErsatzTV.Infrastructure.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -16,15 +18,18 @@ namespace ErsatzTV.Services
|
||||
public class SchedulerService : IHostedService
|
||||
{
|
||||
private readonly ChannelWriter<IBackgroundServiceRequest> _channel;
|
||||
private readonly IEntityLocker _entityLocker;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private Timer _timer;
|
||||
|
||||
public SchedulerService(
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
ChannelWriter<IBackgroundServiceRequest> channel)
|
||||
ChannelWriter<IBackgroundServiceRequest> channel,
|
||||
IEntityLocker entityLocker)
|
||||
{
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_channel = channel;
|
||||
_entityLocker = entityLocker;
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
@@ -75,7 +80,12 @@ namespace ErsatzTV.Services
|
||||
|
||||
foreach (int mediaSourceId in localMediaSourceIds)
|
||||
{
|
||||
await _channel.WriteAsync(new ScanLocalMediaSource(mediaSourceId), cancellationToken);
|
||||
if (_entityLocker.LockMediaSource(mediaSourceId))
|
||||
{
|
||||
await _channel.WriteAsync(
|
||||
new ScanLocalMediaSource(mediaSourceId, ScanningMode.Default),
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user