#nullable enable using ErsatzTV.Core.Api.MediaSources; using ErsatzTV.Core.Interfaces.Locking; namespace ErsatzTV.Application.MediaSources; // Reports which media-source families currently hold their external-collections scan lock. The lock // is the running scan (the scan-collections controllers acquire it before enqueueing and the scanner // releases it on completion), so IEntityLocker is the authoritative source — analogous to how // GetLibraryScanStatus reads IScannerProxyService.GetActiveScans(). Collections locks are family-global, // so this returns at most one entry per family, and only for families actively scanning. public class GetCollectionsScanStatusHandler(IEntityLocker entityLocker) : IRequestHandler> { public Task> Handle( GetCollectionsScanStatus request, CancellationToken cancellationToken) { var result = new List(); if (entityLocker.ArePlexCollectionsLocked()) { result.Add(new CollectionsScanStatusResponseModel("plex")); } if (entityLocker.AreJellyfinCollectionsLocked()) { result.Add(new CollectionsScanStatusResponseModel("jellyfin")); } if (entityLocker.AreEmbyCollectionsLocked()) { result.Add(new CollectionsScanStatusResponseModel("emby")); } return Task.FromResult(result); } }