private async Task <Either <BaseError, List <PlexMediaSource> > > SynchronizeAllServers( List <PlexMediaSource> servers) { List <PlexMediaSource> allExisting = await _mediaSourceRepository.GetAllPlex(); foreach (PlexMediaSource server in servers) { await SynchronizeServer(allExisting, server); } // delete removed servers foreach (PlexMediaSource removed in allExisting.Filter( s => servers.All(pms => pms.ClientIdentifier != s.ClientIdentifier))) { _logger.LogWarning("Deleting removed Plex server {ServerName}!", removed.Id.ToString()); await _mediaSourceRepository.DeletePlex(removed); } foreach (PlexMediaSource mediaSource in await _mediaSourceRepository.GetAllPlex()) { await _channel.WriteAsync(new SynchronizePlexLibraries(mediaSource.Id)); } _entityLocker.UnlockPlex(); return(allExisting); }
private async Task <Either <BaseError, List <PlexMediaSource> > > SynchronizeAllServers( List <PlexMediaSource> servers) { List <PlexMediaSource> allExisting = await _mediaSourceRepository.GetAllPlex(); foreach (PlexMediaSource server in servers) { await SynchronizeServer(allExisting, server); } foreach (PlexMediaSource mediaSource in await _mediaSourceRepository.GetAllPlex()) { await _channel.WriteAsync(new SynchronizePlexLibraries(mediaSource.Id)); } _entityLocker.UnlockPlex(); return(allExisting); }