mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 06:18:28 +01:00
update task results
This commit is contained in:
@@ -191,7 +191,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
var dtoOptions = new DtoOptions();
|
||||
|
||||
var returnItems = _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user)
|
||||
var returnItems = (await _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user).ConfigureAwait(false))
|
||||
.ToArray();
|
||||
|
||||
var result = new QueryResult<BaseItemDto>
|
||||
@@ -596,7 +596,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
var dtoOptions = new DtoOptions();
|
||||
|
||||
var returnItems = _dtoService.GetBaseItemDtos(items, dtoOptions, user)
|
||||
var returnItems = (await _dtoService.GetBaseItemDtos(items, dtoOptions, user).ConfigureAwait(false))
|
||||
.ToArray();
|
||||
|
||||
var result = new QueryResult<BaseItemDto>
|
||||
@@ -863,7 +863,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
var dtoOptions = new DtoOptions();
|
||||
|
||||
var returnItems = _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user)
|
||||
var returnItems = (await _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user).ConfigureAwait(false))
|
||||
.ToArray();
|
||||
|
||||
var result = new QueryResult<BaseItemDto>
|
||||
@@ -1012,7 +1012,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
var dtoOptions = new DtoOptions();
|
||||
|
||||
var returnItems = _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user)
|
||||
var returnItems = (await _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user).ConfigureAwait(false))
|
||||
.ToArray();
|
||||
|
||||
var result = new QueryResult<BaseItemDto>
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
|
||||
try
|
||||
{
|
||||
var localAddress = _appHost.LocalApiUrl;
|
||||
var localAddress = await _appHost.GetLocalApiUrl().ConfigureAwait(false);
|
||||
|
||||
var hasExistingRecord = !string.IsNullOrWhiteSpace(ConnectServerId) &&
|
||||
!string.IsNullOrWhiteSpace(ConnectAccessKey);
|
||||
@@ -217,24 +217,26 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
}
|
||||
|
||||
private string _lastReportedIdentifier;
|
||||
private string GetConnectReportingIdentifier()
|
||||
private async Task<string> GetConnectReportingIdentifier()
|
||||
{
|
||||
return GetConnectReportingIdentifier(_appHost.LocalApiUrl, WanApiAddress);
|
||||
var url = await _appHost.GetLocalApiUrl().ConfigureAwait(false);
|
||||
return GetConnectReportingIdentifier(url, WanApiAddress);
|
||||
}
|
||||
private string GetConnectReportingIdentifier(string localAddress, string remoteAddress)
|
||||
{
|
||||
return (remoteAddress ?? string.Empty) + (localAddress ?? string.Empty);
|
||||
}
|
||||
|
||||
void _config_ConfigurationUpdated(object sender, EventArgs e)
|
||||
async void _config_ConfigurationUpdated(object sender, EventArgs e)
|
||||
{
|
||||
// If info hasn't changed, don't report anything
|
||||
if (string.Equals(_lastReportedIdentifier, GetConnectReportingIdentifier(), StringComparison.OrdinalIgnoreCase))
|
||||
var connectIdentifier = await GetConnectReportingIdentifier().ConfigureAwait(false);
|
||||
if (string.Equals(_lastReportedIdentifier, connectIdentifier, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateConnectInfo();
|
||||
await UpdateConnectInfo().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task CreateServerRegistration(string wanApiAddress, string localAddress)
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
return GetBaseItemDto(item, options, user, owner);
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItemDto> GetBaseItemDtos(IEnumerable<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)
|
||||
public async Task<List<BaseItemDto>> GetBaseItemDtos(IEnumerable<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)
|
||||
{
|
||||
var syncJobItems = GetSyncedItemProgress(options);
|
||||
var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems);
|
||||
@@ -97,7 +97,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var dto = GetBaseItemDtoInternal(item, options, syncDictionary, user, owner);
|
||||
var dto = await GetBaseItemDtoInternal(item, options, syncDictionary, user, owner).ConfigureAwait(false);
|
||||
|
||||
var tvChannel = item as LiveTvChannel;
|
||||
if (tvChannel != null)
|
||||
@@ -131,8 +131,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
|
||||
if (programTuples.Count > 0)
|
||||
{
|
||||
var task = _livetvManager().AddInfoToProgramDto(programTuples, options.Fields, user);
|
||||
Task.WaitAll(task);
|
||||
await _livetvManager().AddInfoToProgramDto(programTuples, options.Fields, user).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (channelTuples.Count > 0)
|
||||
@@ -159,7 +158,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
{
|
||||
var syncProgress = GetSyncedItemProgress(options);
|
||||
|
||||
var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user, owner);
|
||||
var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user, owner).Result;
|
||||
var tvChannel = item as LiveTvChannel;
|
||||
if (tvChannel != null)
|
||||
{
|
||||
@@ -300,7 +299,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
}
|
||||
}
|
||||
|
||||
private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, Dictionary<string, SyncedItemProgress> syncProgress, User user = null, BaseItem owner = null)
|
||||
private async Task<BaseItemDto> GetBaseItemDtoInternal(BaseItem item, DtoOptions options, Dictionary<string, SyncedItemProgress> syncProgress, User user = null, BaseItem owner = null)
|
||||
{
|
||||
var fields = options.Fields;
|
||||
|
||||
@@ -349,7 +348,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
AttachUserSpecificInfo(dto, item, user, fields, syncProgress);
|
||||
await AttachUserSpecificInfo(dto, item, user, fields, syncProgress).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var hasMediaSources = item as IHasMediaSources;
|
||||
@@ -416,7 +415,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
{
|
||||
var syncProgress = GetSyncedItemProgress(options);
|
||||
|
||||
var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user);
|
||||
var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user).Result;
|
||||
|
||||
if (taggedItems != null && options.Fields.Contains(ItemFields.ItemCounts))
|
||||
{
|
||||
@@ -465,21 +464,26 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="fields">The fields.</param>
|
||||
/// <param name="syncProgress">The synchronize progress.</param>
|
||||
private void AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, List<ItemFields> fields, Dictionary<string, SyncedItemProgress> syncProgress)
|
||||
private async Task AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, List<ItemFields> fields, Dictionary<string, SyncedItemProgress> syncProgress)
|
||||
{
|
||||
if (item.IsFolder)
|
||||
{
|
||||
var folder = (Folder)item;
|
||||
|
||||
// Skip the user data manager because we've already looped through the recursive tree and don't want to do it twice
|
||||
// TODO: Improve in future
|
||||
dto.UserData = GetUserItemDataDto(_userDataRepository.GetUserData(user, item));
|
||||
|
||||
if (item.SourceType == SourceType.Library && folder.SupportsUserDataFromChildren)
|
||||
if (item.SourceType == SourceType.Library && folder.SupportsUserDataFromChildren && fields.Contains(ItemFields.SyncInfo))
|
||||
{
|
||||
SetSpecialCounts(folder, user, dto, fields, syncProgress);
|
||||
// Skip the user data manager because we've already looped through the recursive tree and don't want to do it twice
|
||||
// TODO: Improve in future
|
||||
dto.UserData = GetUserItemDataDto(_userDataRepository.GetUserData(user, item));
|
||||
|
||||
dto.UserData.Played = dto.UserData.PlayedPercentage.HasValue && dto.UserData.PlayedPercentage.Value >= 100;
|
||||
await SetSpecialCounts(folder, user, dto, fields, syncProgress).ConfigureAwait(false);
|
||||
|
||||
dto.UserData.Played = dto.UserData.PlayedPercentage.HasValue &&
|
||||
dto.UserData.PlayedPercentage.Value >= 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
dto.UserData = await _userDataRepository.GetUserDataDto(item, dto, user).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (item.SourceType == SourceType.Library)
|
||||
@@ -500,7 +504,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
|
||||
else
|
||||
{
|
||||
dto.UserData = _userDataRepository.GetUserDataDto(item, user);
|
||||
dto.UserData = _userDataRepository.GetUserDataDto(item, user).Result;
|
||||
}
|
||||
|
||||
dto.PlayAccess = item.GetPlayAccess(user);
|
||||
@@ -515,7 +519,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
|
||||
if (season != null)
|
||||
{
|
||||
dto.SeasonUserData = _userDataRepository.GetUserDataDto(season, user);
|
||||
dto.SeasonUserData = await _userDataRepository.GetUserDataDto(season, user).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1588,32 +1592,25 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
/// <param name="fields">The fields.</param>
|
||||
/// <param name="syncProgress">The synchronize progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private void SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List<ItemFields> fields, Dictionary<string, SyncedItemProgress> syncProgress)
|
||||
private async Task SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List<ItemFields> fields, Dictionary<string, SyncedItemProgress> syncProgress)
|
||||
{
|
||||
var addSyncInfo = fields.Contains(ItemFields.SyncInfo);
|
||||
|
||||
if (!addSyncInfo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var recursiveItemCount = 0;
|
||||
var unplayed = 0;
|
||||
|
||||
double totalPercentPlayed = 0;
|
||||
double totalSyncPercent = 0;
|
||||
|
||||
var children = folder.GetItems(new InternalItemsQuery
|
||||
var children = await folder.GetItems(new InternalItemsQuery
|
||||
{
|
||||
IsFolder = false,
|
||||
Recursive = true,
|
||||
ExcludeLocationTypes = new[] { LocationType.Virtual },
|
||||
ExcludeLocationTypes = new[] {LocationType.Virtual},
|
||||
User = user
|
||||
|
||||
}).Result.Items;
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
// Loop through each recursive child
|
||||
foreach (var child in children)
|
||||
foreach (var child in children.Items)
|
||||
{
|
||||
var userdata = _userDataRepository.GetUserData(user, child);
|
||||
|
||||
@@ -1643,26 +1640,23 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
unplayed++;
|
||||
}
|
||||
|
||||
if (addSyncInfo)
|
||||
double percent = 0;
|
||||
SyncedItemProgress syncItemProgress;
|
||||
if (syncProgress.TryGetValue(child.Id.ToString("N"), out syncItemProgress))
|
||||
{
|
||||
double percent = 0;
|
||||
SyncedItemProgress syncItemProgress;
|
||||
if (syncProgress.TryGetValue(child.Id.ToString("N"), out syncItemProgress))
|
||||
switch (syncItemProgress.Status)
|
||||
{
|
||||
switch (syncItemProgress.Status)
|
||||
{
|
||||
case SyncJobItemStatus.Synced:
|
||||
percent = 100;
|
||||
break;
|
||||
case SyncJobItemStatus.Converting:
|
||||
case SyncJobItemStatus.ReadyToTransfer:
|
||||
case SyncJobItemStatus.Transferring:
|
||||
percent = 50;
|
||||
break;
|
||||
}
|
||||
case SyncJobItemStatus.Synced:
|
||||
percent = 100;
|
||||
break;
|
||||
case SyncJobItemStatus.Converting:
|
||||
case SyncJobItemStatus.ReadyToTransfer:
|
||||
case SyncJobItemStatus.Transferring:
|
||||
percent = 50;
|
||||
break;
|
||||
}
|
||||
totalSyncPercent += percent;
|
||||
}
|
||||
totalSyncPercent += percent;
|
||||
}
|
||||
|
||||
dto.RecursiveItemCount = recursiveItemCount;
|
||||
@@ -1672,13 +1666,10 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
{
|
||||
dto.UserData.PlayedPercentage = totalPercentPlayed / recursiveItemCount;
|
||||
|
||||
if (addSyncInfo)
|
||||
var pct = totalSyncPercent / recursiveItemCount;
|
||||
if (pct > 0)
|
||||
{
|
||||
var pct = totalSyncPercent / recursiveItemCount;
|
||||
if (pct > 0)
|
||||
{
|
||||
dto.SyncPercent = pct;
|
||||
}
|
||||
dto.SyncPercent = pct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using MediaBrowser.Model.Tasks;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
|
||||
@@ -52,24 +53,29 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
}
|
||||
}
|
||||
|
||||
private void TimerCallback(object state)
|
||||
private async void TimerCallback(object state)
|
||||
{
|
||||
if (_config.Configuration.EnableAutomaticRestart && IsIdle())
|
||||
if (_config.Configuration.EnableAutomaticRestart)
|
||||
{
|
||||
DisposeTimer();
|
||||
var isIdle = await IsIdle().ConfigureAwait(false);
|
||||
|
||||
try
|
||||
if (isIdle)
|
||||
{
|
||||
_appHost.Restart();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error restarting server", ex);
|
||||
DisposeTimer();
|
||||
|
||||
try
|
||||
{
|
||||
_appHost.Restart();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error restarting server", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsIdle()
|
||||
private async Task<bool> IsIdle()
|
||||
{
|
||||
if (_iTaskManager.ScheduledTasks.Any(i => i.State != TaskState.Idle))
|
||||
{
|
||||
@@ -80,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
{
|
||||
try
|
||||
{
|
||||
var timers = _liveTvManager.GetTimers(new TimerQuery(), CancellationToken.None).Result;
|
||||
var timers = await _liveTvManager.GetTimers(new TimerQuery(), CancellationToken.None).ConfigureAwait(false);
|
||||
if (timers.Items.Any(i => i.Status == RecordingStatus.InProgress))
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
.DistinctBy(i => i.Id)
|
||||
.Select(i =>
|
||||
{
|
||||
var dto = _userDataManager.GetUserDataDto(i, user);
|
||||
var dto = _userDataManager.GetUserDataDto(i, user).Result;
|
||||
dto.ItemId = i.Id.ToString("N");
|
||||
return dto;
|
||||
})
|
||||
|
||||
@@ -294,7 +294,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
return null;
|
||||
}
|
||||
|
||||
public object GetStaticFileResult(IRequest requestContext,
|
||||
public Task<object> GetStaticFileResult(IRequest requestContext,
|
||||
string path,
|
||||
FileShare fileShare = FileShare.Read)
|
||||
{
|
||||
@@ -310,7 +310,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
});
|
||||
}
|
||||
|
||||
public object GetStaticFileResult(IRequest requestContext,
|
||||
public Task<object> GetStaticFileResult(IRequest requestContext,
|
||||
StaticFileResultOptions options)
|
||||
{
|
||||
var path = options.Path;
|
||||
@@ -351,7 +351,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
return _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, fileShare);
|
||||
}
|
||||
|
||||
public object GetStaticResult(IRequest requestContext,
|
||||
public Task<object> GetStaticResult(IRequest requestContext,
|
||||
Guid cacheKey,
|
||||
DateTime? lastDateModified,
|
||||
TimeSpan? cacheDuration,
|
||||
@@ -372,7 +372,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
});
|
||||
}
|
||||
|
||||
public object GetStaticResult(IRequest requestContext, StaticResultOptions options)
|
||||
public async Task<object> GetStaticResult(IRequest requestContext, StaticResultOptions options)
|
||||
{
|
||||
var cacheKey = options.CacheKey;
|
||||
options.ResponseHeaders = options.ResponseHeaders ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -398,7 +398,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
}
|
||||
|
||||
var compress = ShouldCompressResponse(requestContext, contentType);
|
||||
var hasOptions = GetStaticResult(requestContext, options, compress).Result;
|
||||
var hasOptions = await GetStaticResult(requestContext, options, compress).ConfigureAwait(false);
|
||||
AddResponseHeaders(hasOptions, options.ResponseHeaders);
|
||||
|
||||
return hasOptions;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
|
||||
var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', Path.DirectorySeparatorChar));
|
||||
|
||||
return ResultFactory.GetStaticFileResult(Request, requestedFile);
|
||||
return ResultFactory.GetStaticFileResult(Request, requestedFile).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1398,7 +1398,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.Debug("Query requires ancestor query due to type: " + i.GetType().Name);
|
||||
//_logger.Debug("Query requires ancestor query due to type: " + i.GetType().Name);
|
||||
return false;
|
||||
|
||||
}))
|
||||
|
||||
@@ -202,12 +202,21 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return GetUserData(userId, item.Id, item.GetUserDataKeys());
|
||||
}
|
||||
|
||||
public UserItemDataDto GetUserDataDto(IHasUserData item, User user)
|
||||
public async Task<UserItemDataDto> GetUserDataDto(IHasUserData item, User user)
|
||||
{
|
||||
var userData = GetUserData(user.Id, item);
|
||||
var dto = GetUserItemDataDto(userData);
|
||||
|
||||
item.FillUserDataDtoValues(dto, userData, user);
|
||||
await item.FillUserDataDtoValues(dto, userData, null, user).ConfigureAwait(false);
|
||||
return dto;
|
||||
}
|
||||
|
||||
public async Task<UserItemDataDto> GetUserDataDto(IHasUserData item, BaseItemDto itemDto, User user)
|
||||
{
|
||||
var userData = GetUserData(user.Id, item);
|
||||
var dto = GetUserItemDataDto(userData);
|
||||
|
||||
await item.FillUserDataDtoValues(dto, userData, itemDto, user).ConfigureAwait(false);
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
@@ -729,7 +729,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
var text = new StringBuilder();
|
||||
|
||||
var localAddress = _appHost.LocalApiUrl ?? string.Empty;
|
||||
var localAddress = _appHost.GetLocalApiUrl().Result ?? string.Empty;
|
||||
|
||||
text.AppendLine("Use your web browser to visit:");
|
||||
text.AppendLine(string.Empty);
|
||||
|
||||
@@ -924,7 +924,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
var queryResult = _libraryManager.QueryItems(internalQuery);
|
||||
|
||||
var returnArray = _dtoService.GetBaseItemDtos(queryResult.Items, options, user).ToArray();
|
||||
var returnArray = (await _dtoService.GetBaseItemDtos(queryResult.Items, options, user).ConfigureAwait(false)).ToArray();
|
||||
|
||||
var result = new QueryResult<BaseItemDto>
|
||||
{
|
||||
@@ -1001,7 +1001,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
var user = _userManager.GetUserById(query.UserId);
|
||||
|
||||
var returnArray = _dtoService.GetBaseItemDtos(internalResult.Items, options, user).ToArray();
|
||||
var returnArray = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user).ConfigureAwait(false)).ToArray();
|
||||
|
||||
var result = new QueryResult<BaseItemDto>
|
||||
{
|
||||
@@ -1638,7 +1638,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
var internalResult = await GetInternalRecordings(query, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var returnArray = _dtoService.GetBaseItemDtos(internalResult.Items, options, user).ToArray();
|
||||
var returnArray = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user).ConfigureAwait(false)).ToArray();
|
||||
|
||||
return new QueryResult<BaseItemDto>
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
}
|
||||
|
||||
var list = sources.ToList();
|
||||
var serverUrl = _appHost.LocalApiUrl;
|
||||
var serverUrl = await _appHost.GetLocalApiUrl().ConfigureAwait(false);
|
||||
|
||||
foreach (var source in list)
|
||||
{
|
||||
|
||||
@@ -932,7 +932,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
return session.SessionController.SendGeneralCommand(command, cancellationToken);
|
||||
}
|
||||
|
||||
public Task SendPlayCommand(string controllingSessionId, string sessionId, PlayRequest command, CancellationToken cancellationToken)
|
||||
public async Task SendPlayCommand(string controllingSessionId, string sessionId, PlayRequest command, CancellationToken cancellationToken)
|
||||
{
|
||||
var session = GetSessionToRemoteControl(sessionId);
|
||||
|
||||
@@ -950,7 +950,14 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
}
|
||||
else
|
||||
{
|
||||
items = command.ItemIds.SelectMany(i => TranslateItemForPlayback(i, user))
|
||||
var list = new List<BaseItem>();
|
||||
foreach (var itemId in command.ItemIds)
|
||||
{
|
||||
var subItems = await TranslateItemForPlayback(itemId, user).ConfigureAwait(false);
|
||||
list.AddRange(subItems);
|
||||
}
|
||||
|
||||
items = list
|
||||
.Where(i => i.LocationType != LocationType.Virtual)
|
||||
.ToList();
|
||||
}
|
||||
@@ -1013,10 +1020,10 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
command.ControllingUserId = controllingSession.UserId.Value.ToString("N");
|
||||
}
|
||||
|
||||
return session.SessionController.SendPlayCommand(command, cancellationToken);
|
||||
await session.SessionController.SendPlayCommand(command, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private IEnumerable<BaseItem> TranslateItemForPlayback(string id, User user)
|
||||
private async Task<List<BaseItem>> TranslateItemForPlayback(string id, User user)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(id);
|
||||
|
||||
@@ -1037,25 +1044,27 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
});
|
||||
|
||||
return FilterToSingleMediaType(items)
|
||||
.OrderBy(i => i.SortName);
|
||||
.OrderBy(i => i.SortName)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
if (item.IsFolder)
|
||||
{
|
||||
var folder = (Folder)item;
|
||||
|
||||
var items = folder.GetItems(new InternalItemsQuery(user)
|
||||
var itemsResult = await folder.GetItems(new InternalItemsQuery(user)
|
||||
{
|
||||
Recursive = true,
|
||||
IsFolder = false
|
||||
|
||||
}).Result.Items;
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
return FilterToSingleMediaType(items)
|
||||
.OrderBy(i => i.SortName);
|
||||
return FilterToSingleMediaType(itemsResult.Items)
|
||||
.OrderBy(i => i.SortName)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return new[] { item };
|
||||
return new List<BaseItem> { item };
|
||||
}
|
||||
|
||||
private IEnumerable<BaseItem> FilterToSingleMediaType(IEnumerable<BaseItem> items)
|
||||
|
||||
@@ -234,10 +234,22 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
|
||||
public async Task<IEnumerable<BaseItem>> GetItemsForSync(SyncCategory? category, string parentId, IEnumerable<string> itemIds, User user, bool unwatchedOnly)
|
||||
{
|
||||
var items = category.HasValue ?
|
||||
await GetItemsForSync(category.Value, parentId, user).ConfigureAwait(false) :
|
||||
itemIds.SelectMany(i => GetItemsForSync(i, user));
|
||||
var list = new List<BaseItem>();
|
||||
|
||||
if (category.HasValue)
|
||||
{
|
||||
list = (await GetItemsForSync(category.Value, parentId, user).ConfigureAwait(false)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var itemId in itemIds)
|
||||
{
|
||||
var subList = await GetItemsForSync(itemId, user).ConfigureAwait(false);
|
||||
list.AddRange(subList);
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<BaseItem> items = list;
|
||||
items = items.Where(_syncManager.SupportsSync);
|
||||
|
||||
if (unwatchedOnly)
|
||||
@@ -314,7 +326,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
return result.Items;
|
||||
}
|
||||
|
||||
private IEnumerable<BaseItem> GetItemsForSync(string id, User user)
|
||||
private async Task<List<BaseItem>> GetItemsForSync(string id, User user)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(id);
|
||||
|
||||
@@ -330,18 +342,20 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
{
|
||||
IsFolder = false,
|
||||
Recursive = true
|
||||
});
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
if (item.IsFolder)
|
||||
{
|
||||
var folder = (Folder)item;
|
||||
var items = folder.GetItems(new InternalItemsQuery(user)
|
||||
var itemsResult = await folder.GetItems(new InternalItemsQuery(user)
|
||||
{
|
||||
Recursive = true,
|
||||
IsFolder = false
|
||||
|
||||
}).Result.Items;
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
var items = itemsResult.Items;
|
||||
|
||||
if (!folder.IsPreSorted)
|
||||
{
|
||||
@@ -349,10 +363,10 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
return items;
|
||||
return items.ToList();
|
||||
}
|
||||
|
||||
return new[] { item };
|
||||
return new List<BaseItem> { item };
|
||||
}
|
||||
|
||||
private async Task EnsureSyncJobItems(string targetId, CancellationToken cancellationToken)
|
||||
|
||||
@@ -96,20 +96,20 @@ namespace MediaBrowser.Server.Implementations.Udp
|
||||
|
||||
private async void RespondToV1Message(string endpoint, Encoding encoding)
|
||||
{
|
||||
var localAddress = _appHost.LocalApiUrl;
|
||||
var localUrl = await _appHost.GetLocalApiUrl().ConfigureAwait(false);
|
||||
|
||||
if (!string.IsNullOrEmpty(localAddress))
|
||||
if (!string.IsNullOrEmpty(localUrl))
|
||||
{
|
||||
// This is how we did the old v1 search, so need to strip off the protocol
|
||||
var index = localAddress.IndexOf("://", StringComparison.OrdinalIgnoreCase);
|
||||
var index = localUrl.IndexOf("://", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
localAddress = localAddress.Substring(index + 3);
|
||||
localUrl = localUrl.Substring(index + 3);
|
||||
}
|
||||
|
||||
// Send a response back with our ip address and port
|
||||
var response = String.Format("MediaBrowserServer|{0}", localAddress);
|
||||
var response = String.Format("MediaBrowserServer|{0}", localUrl);
|
||||
|
||||
await SendAsync(Encoding.UTF8.GetBytes(response), endpoint);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ namespace MediaBrowser.Server.Implementations.Udp
|
||||
|
||||
private async void RespondToV2Message(string endpoint, Encoding encoding)
|
||||
{
|
||||
var localUrl = _appHost.LocalApiUrl;
|
||||
var localUrl = await _appHost.GetLocalApiUrl().ConfigureAwait(false);
|
||||
|
||||
if (!string.IsNullOrEmpty(localUrl))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user