Merge pull request #2011 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-08-02 01:57:21 -04:00 committed by GitHub
commit b90c18b7f3
5 changed files with 19 additions and 42 deletions

View File

@ -219,6 +219,7 @@
/// </summary>
Studios,
BasicSyncInfo,
/// <summary>
/// The synchronize information
/// </summary>

View File

@ -133,7 +133,7 @@ namespace MediaBrowser.Server.Implementations.Dto
}
}
FillSyncInfo(dto, item, syncJobItems, options, user);
FillSyncInfo(dto, item, options, user, syncJobItems);
list.Add(dto);
}
@ -253,14 +253,16 @@ namespace MediaBrowser.Server.Implementations.Dto
{
var item = tuple.Item1;
FillSyncInfo(tuple.Item2, item, syncProgress, options, user);
FillSyncInfo(tuple.Item2, item, options, user, syncProgress);
}
}
}
private void FillSyncInfo(IHasSyncInfo dto, BaseItem item, DtoOptions options, User user, SyncedItemProgress[] syncProgress)
{
if (options.Fields.Contains(ItemFields.SyncInfo))
var hasFullSyncInfo = options.Fields.Contains(ItemFields.SyncInfo);
if (hasFullSyncInfo || options.Fields.Contains(ItemFields.BasicSyncInfo))
{
var userCanSync = user != null && user.Policy.EnableSync;
dto.SupportsSync = userCanSync && _syncManager.SupportsSync(item);
@ -271,39 +273,17 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.HasSyncJob = syncProgress.Any(i => i.Status != SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase));
dto.IsSynced = syncProgress.Any(i => i.Status == SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase));
if (dto.IsSynced.Value)
if (hasFullSyncInfo)
{
dto.SyncStatus = SyncJobItemStatus.Synced;
}
if (dto.IsSynced.Value)
{
dto.SyncStatus = SyncJobItemStatus.Synced;
}
else if (dto.HasSyncJob.Value)
{
dto.SyncStatus = syncProgress.Where(i => string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)).Select(i => i.Status).Max();
}
}
}
private void FillSyncInfo(IHasSyncInfo dto, BaseItem item, SyncedItemProgress[] syncProgress, DtoOptions options, User user)
{
if (options.Fields.Contains(ItemFields.SyncInfo))
{
var userCanSync = user != null && user.Policy.EnableSync;
dto.SupportsSync = userCanSync && _syncManager.SupportsSync(item);
}
if (dto.SupportsSync ?? false)
{
dto.HasSyncJob = syncProgress.Any(i => i.Status != SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase));
dto.IsSynced = syncProgress.Any(i => i.Status == SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase));
if (dto.IsSynced.Value)
{
dto.SyncStatus = SyncJobItemStatus.Synced;
}
else if (dto.HasSyncJob.Value)
{
dto.SyncStatus = syncProgress.Where(i => string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)).Select(i => i.Status).Max();
else if (dto.HasSyncJob.Value)
{
dto.SyncStatus = syncProgress.Where(i => string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)).Select(i => i.Status).Max();
}
}
}
}

View File

@ -1187,6 +1187,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
// Load these now which will prefetch metadata
var dtoOptions = new DtoOptions();
dtoOptions.Fields.Remove(ItemFields.SyncInfo);
dtoOptions.Fields.Remove(ItemFields.BasicSyncInfo);
await GetRecordings(new RecordingQuery(), dtoOptions, cancellationToken).ConfigureAwait(false);
progress.Report(100);

View File

@ -646,6 +646,7 @@ namespace MediaBrowser.Server.Implementations.Sync
dtoOptions.Fields.Remove(ItemFields.SeriesGenres);
dtoOptions.Fields.Remove(ItemFields.Settings);
dtoOptions.Fields.Remove(ItemFields.SyncInfo);
dtoOptions.Fields.Remove(ItemFields.BasicSyncInfo);
syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, dtoOptions);

View File

@ -199,10 +199,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
// int.TryParse is local aware, so it can be probamatic, force us culture
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval))
{
if ((item.ParentIndexNumber ?? 0) == 0)
{
item.AirsBeforeSeasonNumber = rval;
}
item.AirsBeforeSeasonNumber = rval;
}
}
@ -220,10 +217,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
// int.TryParse is local aware, so it can be probamatic, force us culture
if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval))
{
if ((item.ParentIndexNumber ?? 0) == 0)
{
item.AirsBeforeEpisodeNumber = rval;
}
item.AirsBeforeEpisodeNumber = rval;
}
}