restore changes

This commit is contained in:
Luke Pulverenti 2015-11-23 11:04:57 -05:00
parent 4294df7a81
commit 1ee7826be6
3 changed files with 85 additions and 109 deletions

View File

@ -28,7 +28,6 @@ namespace MediaBrowser.Controller.Entities
public List<Guid> ThemeSongIds { get; set; } public List<Guid> ThemeSongIds { get; set; }
public List<Guid> ThemeVideoIds { get; set; } public List<Guid> ThemeVideoIds { get; set; }
public List<string> Tags { get; set; }
public Folder() public Folder()
{ {
@ -36,7 +35,6 @@ namespace MediaBrowser.Controller.Entities
ThemeSongIds = new List<Guid>(); ThemeSongIds = new List<Guid>();
ThemeVideoIds = new List<Guid>(); ThemeVideoIds = new List<Guid>();
Tags = new List<string>();
} }
[IgnoreDataMember] [IgnoreDataMember]
@ -151,7 +149,15 @@ namespace MediaBrowser.Controller.Entities
await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false); if (!EnableNewFolderQuerying())
{
await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
}
}
private static bool EnableNewFolderQuerying()
{
return ConfigurationManager.Configuration.MigrationVersion >= 1;
} }
protected void AddChildrenInternal(IEnumerable<BaseItem> children) protected void AddChildrenInternal(IEnumerable<BaseItem> children)
@ -196,21 +202,6 @@ namespace MediaBrowser.Controller.Entities
} }
} }
[IgnoreDataMember]
public override string OfficialRatingForComparison
{
get
{
// Never want folders to be blocked by "BlockNotRated"
if (this is Series)
{
return base.OfficialRatingForComparison;
}
return !string.IsNullOrWhiteSpace(base.OfficialRatingForComparison) ? base.OfficialRatingForComparison : "None";
}
}
/// <summary> /// <summary>
/// Removes the child. /// Removes the child.
/// </summary> /// </summary>
@ -224,7 +215,12 @@ namespace MediaBrowser.Controller.Entities
item.SetParent(null); item.SetParent(null);
return ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken); if (!EnableNewFolderQuerying())
{
return ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken);
}
return Task.FromResult(true);
} }
/// <summary> /// <summary>
@ -457,32 +453,25 @@ namespace MediaBrowser.Controller.Entities
{ {
BaseItem currentChild; BaseItem currentChild;
if (currentChildren.TryGetValue(child.Id, out currentChild)) if (currentChildren.TryGetValue(child.Id, out currentChild) && IsValidFromResolver(currentChild, child))
{ {
if (IsValidFromResolver(currentChild, child)) var currentChildLocationType = currentChild.LocationType;
if (currentChildLocationType != LocationType.Remote &&
currentChildLocationType != LocationType.Virtual)
{ {
var currentChildLocationType = currentChild.LocationType; currentChild.DateModified = child.DateModified;
if (currentChildLocationType != LocationType.Remote && }
currentChildLocationType != LocationType.Virtual)
{
currentChild.DateModified = child.DateModified;
}
await UpdateIsOffline(currentChild, false).ConfigureAwait(false); await UpdateIsOffline(currentChild, false).ConfigureAwait(false);
validChildren.Add(currentChild); validChildren.Add(currentChild);
}
else continue;
{
newItems.Add(child);
validChildren.Add(child);
}
}
else
{
// Brand new item - needs to be added
newItems.Add(child);
validChildren.Add(child);
} }
// Brand new item - needs to be added
child.SetParent(this);
newItems.Add(child);
validChildren.Add(child);
} }
// If any items were added or removed.... // If any items were added or removed....
@ -508,7 +497,6 @@ namespace MediaBrowser.Controller.Entities
} }
else else
{ {
await UpdateIsOffline(item, false).ConfigureAwait(false);
actualRemovals.Add(item); actualRemovals.Add(item);
} }
} }
@ -519,6 +507,11 @@ namespace MediaBrowser.Controller.Entities
foreach (var item in actualRemovals) foreach (var item in actualRemovals)
{ {
Logger.Debug("Removed item: " + item.Path);
item.SetParent(null);
item.IsOffline = false;
await LibraryManager.DeleteItem(item, new DeleteOptions { DeleteFileLocation = false }).ConfigureAwait(false);
LibraryManager.ReportItemRemoved(item); LibraryManager.ReportItemRemoved(item);
} }
} }
@ -527,7 +520,10 @@ namespace MediaBrowser.Controller.Entities
AddChildrenInternal(newItems); AddChildrenInternal(newItems);
await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false); if (!EnableNewFolderQuerying())
{
await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false);
}
} }
} }
@ -721,7 +717,7 @@ namespace MediaBrowser.Controller.Entities
return true; return true;
} }
return ContainsPath(LibraryManager.GetVirtualFolders(), originalPath); return false;
} }
/// <summary> /// <summary>
@ -757,19 +753,16 @@ namespace MediaBrowser.Controller.Entities
/// <returns>IEnumerable{BaseItem}.</returns> /// <returns>IEnumerable{BaseItem}.</returns>
protected IEnumerable<BaseItem> GetCachedChildren() protected IEnumerable<BaseItem> GetCachedChildren()
{ {
if (ConfigurationManager.Configuration.DisableStartupScan) if (EnableNewFolderQuerying())
{ {
return ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null); return ItemRepository.GetItemList(new InternalItemsQuery
//return ItemRepository.GetItems(new InternalItemsQuery {
//{ ParentId = Id
// ParentId = Id
//}).Items.Select(RetrieveChild).Where(i => i != null); }).Select(RetrieveChild).Where(i => i != null);
}
else
{
return ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null);
} }
return ItemRepository.GetChildrenItems(Id).Select(RetrieveChild).Where(i => i != null);
} }
private BaseItem RetrieveChild(BaseItem child) private BaseItem RetrieveChild(BaseItem child)
@ -832,19 +825,7 @@ namespace MediaBrowser.Controller.Entities
return UserViewBuilder.PostFilterAndSort(items, this, null, query, LibraryManager); return UserViewBuilder.PostFilterAndSort(items, this, null, query, LibraryManager);
} }
/// <summary>
/// Gets allowed children of an item
/// </summary>
/// <param name="user">The user.</param>
/// <param name="includeLinkedChildren">if set to <c>true</c> [include linked children].</param>
/// <returns>IEnumerable{BaseItem}.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public virtual IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren) public virtual IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
{
return GetChildren(user, includeLinkedChildren, false);
}
internal IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren, bool includeHidden)
{ {
if (user == null) if (user == null)
{ {
@ -856,7 +837,7 @@ namespace MediaBrowser.Controller.Entities
var result = new Dictionary<Guid, BaseItem>(); var result = new Dictionary<Guid, BaseItem>();
AddChildren(user, includeLinkedChildren, result, includeHidden, false, null); AddChildren(user, includeLinkedChildren, result, false, null);
return result.Values; return result.Values;
} }
@ -872,29 +853,25 @@ namespace MediaBrowser.Controller.Entities
/// <param name="user">The user.</param> /// <param name="user">The user.</param>
/// <param name="includeLinkedChildren">if set to <c>true</c> [include linked children].</param> /// <param name="includeLinkedChildren">if set to <c>true</c> [include linked children].</param>
/// <param name="result">The result.</param> /// <param name="result">The result.</param>
/// <param name="includeHidden">if set to <c>true</c> [include hidden].</param>
/// <param name="recursive">if set to <c>true</c> [recursive].</param> /// <param name="recursive">if set to <c>true</c> [recursive].</param>
/// <param name="filter">The filter.</param> /// <param name="filter">The filter.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
private void AddChildren(User user, bool includeLinkedChildren, Dictionary<Guid, BaseItem> result, bool includeHidden, bool recursive, Func<BaseItem, bool> filter) private void AddChildren(User user, bool includeLinkedChildren, Dictionary<Guid, BaseItem> result, bool recursive, Func<BaseItem, bool> filter)
{ {
foreach (var child in GetEligibleChildrenForRecursiveChildren(user)) foreach (var child in GetEligibleChildrenForRecursiveChildren(user))
{ {
if (child.IsVisible(user)) if (child.IsVisible(user))
{ {
if (includeHidden || !child.IsHiddenFromUser(user)) if (filter == null || filter(child))
{ {
if (filter == null || filter(child)) result[child.Id] = child;
{
result[child.Id] = child;
}
} }
if (recursive && child.IsFolder) if (recursive && child.IsFolder)
{ {
var folder = (Folder)child; var folder = (Folder)child;
folder.AddChildren(user, includeLinkedChildren, result, includeHidden, true, filter); folder.AddChildren(user, includeLinkedChildren, result, true, filter);
} }
} }
} }
@ -935,7 +912,7 @@ namespace MediaBrowser.Controller.Entities
var result = new Dictionary<Guid, BaseItem>(); var result = new Dictionary<Guid, BaseItem>();
AddChildren(user, true, result, false, true, filter); AddChildren(user, true, result, true, filter);
return result.Values; return result.Values;
} }
@ -1184,6 +1161,7 @@ namespace MediaBrowser.Controller.Entities
Recursive = true, Recursive = true,
IsFolder = false, IsFolder = false,
IsUnaired = false IsUnaired = false
}; };
if (!user.Configuration.DisplayMissingEpisodes) if (!user.Configuration.DisplayMissingEpisodes)
@ -1322,4 +1300,4 @@ namespace MediaBrowser.Controller.Entities
} }
} }
} }
} }

View File

@ -93,7 +93,7 @@ namespace MediaBrowser.Providers.Folders
} }
if (string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) if (string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{ {
//return urlPrefix + "tv.jpg"; return urlPrefix + "tv.jpg";
} }
if (string.Equals(viewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase)) if (string.Equals(viewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase))
{ {
@ -105,7 +105,7 @@ namespace MediaBrowser.Providers.Folders
} }
if (string.Equals(viewType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) if (string.Equals(viewType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
{ {
//return urlPrefix + "movies.jpg"; return urlPrefix + "movies.jpg";
} }
if (string.Equals(viewType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)) if (string.Equals(viewType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase))
{ {
@ -170,4 +170,4 @@ namespace MediaBrowser.Providers.Folders
return GetSupportedImages(item).Any(i => !item.HasImage(i)); return GetSupportedImages(item).Any(i => !item.HasImage(i));
} }
} }
} }

View File

@ -560,6 +560,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
} }
item.ExternalId = channelInfo.Id; item.ExternalId = channelInfo.Id;
if (!item.ParentId.Equals(parentFolderId))
{
isNew = true;
}
item.ParentId = parentFolderId;
item.ChannelType = channelInfo.ChannelType; item.ChannelType = channelInfo.ChannelType;
item.ServiceName = serviceName; item.ServiceName = serviceName;
item.Number = channelInfo.Number; item.Number = channelInfo.Number;
@ -622,6 +628,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
}; };
} }
if (!item.ParentId.Equals(channel.Id))
{
forceUpdate = true;
}
item.ParentId = channel.Id;
//item.ChannelType = channelType; //item.ChannelType = channelType;
if (!string.Equals(item.ServiceName, serviceName, StringComparison.Ordinal)) if (!string.Equals(item.ServiceName, serviceName, StringComparison.Ordinal))
{ {
@ -774,6 +786,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
} }
recording.IsSeries = info.IsSeries; recording.IsSeries = info.IsSeries;
if (!item.ParentId.Equals(parentFolderId))
{
dataChanged = true;
}
item.ParentId = parentFolderId;
if (!item.HasImage(ImageType.Primary)) if (!item.HasImage(ImageType.Primary))
{ {
if (!string.IsNullOrWhiteSpace(info.ImagePath)) if (!string.IsNullOrWhiteSpace(info.ImagePath))
@ -851,7 +869,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{ {
var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId); var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);
var internalQuery = new InternalItemsQuery var internalQuery = new InternalItemsQuery(user)
{ {
IncludeItemTypes = new[] { typeof(LiveTvProgram).Name }, IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
MinEndDate = query.MinEndDate, MinEndDate = query.MinEndDate,
@ -869,16 +887,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
SortOrder = query.SortOrder ?? SortOrder.Ascending SortOrder = query.SortOrder ?? SortOrder.Ascending
}; };
if (user != null)
{
internalQuery.MaxParentalRating = user.Policy.MaxParentalRating;
if (user.Policy.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram))
{
internalQuery.HasParentalRating = true;
}
}
if (query.HasAired.HasValue) if (query.HasAired.HasValue)
{ {
if (query.HasAired.Value) if (query.HasAired.Value)
@ -913,7 +921,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{ {
var user = _userManager.GetUserById(query.UserId); var user = _userManager.GetUserById(query.UserId);
var internalQuery = new InternalItemsQuery var internalQuery = new InternalItemsQuery(user)
{ {
IncludeItemTypes = new[] { typeof(LiveTvProgram).Name }, IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
IsAiring = query.IsAiring, IsAiring = query.IsAiring,
@ -922,16 +930,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
IsKids = query.IsKids IsKids = query.IsKids
}; };
if (user != null)
{
internalQuery.MaxParentalRating = user.Policy.MaxParentalRating;
if (user.Policy.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram))
{
internalQuery.HasParentalRating = true;
}
}
if (query.HasAired.HasValue) if (query.HasAired.HasValue)
{ {
if (query.HasAired.Value) if (query.HasAired.Value)
@ -1399,7 +1397,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
await RefreshRecordings(cancellationToken).ConfigureAwait(false); await RefreshRecordings(cancellationToken).ConfigureAwait(false);
var internalQuery = new InternalItemsQuery var internalQuery = new InternalItemsQuery(user)
{ {
IncludeItemTypes = new[] { typeof(LiveTvVideoRecording).Name, typeof(LiveTvAudioRecording).Name } IncludeItemTypes = new[] { typeof(LiveTvVideoRecording).Name, typeof(LiveTvAudioRecording).Name }
}; };
@ -1409,8 +1407,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
internalQuery.ChannelIds = new[] { query.ChannelId }; internalQuery.ChannelIds = new[] { query.ChannelId };
} }
var queryResult = _libraryManager.GetItems(internalQuery); var queryResult = _libraryManager.GetItems(internalQuery, new string[] { });
IEnumerable<ILiveTvRecording> recordings = queryResult.Items.Cast<ILiveTvRecording>(); IEnumerable<ILiveTvRecording> recordings = queryResult.Cast<ILiveTvRecording>();
if (!string.IsNullOrEmpty(query.Id)) if (!string.IsNullOrEmpty(query.Id))
{ {
@ -1812,7 +1810,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var now = DateTime.UtcNow; var now = DateTime.UtcNow;
var programs = _libraryManager.GetItems(new InternalItemsQuery var programs = _libraryManager.GetItems(new InternalItemsQuery(user)
{ {
IncludeItemTypes = new[] { typeof(LiveTvProgram).Name }, IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
ChannelIds = new[] { id }, ChannelIds = new[] { id },
@ -1821,7 +1819,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
Limit = 1, Limit = 1,
SortBy = new[] { "StartDate" } SortBy = new[] { "StartDate" }
}).Items.Cast<LiveTvProgram>(); }, new string[] { }).Cast<LiveTvProgram>();
var currentProgram = programs.FirstOrDefault(); var currentProgram = programs.FirstOrDefault();
@ -1836,7 +1834,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var now = DateTime.UtcNow; var now = DateTime.UtcNow;
var programs = _libraryManager.GetItems(new InternalItemsQuery var programs = _libraryManager.GetItems(new InternalItemsQuery(user)
{ {
IncludeItemTypes = new[] { typeof(LiveTvProgram).Name }, IncludeItemTypes = new[] { typeof(LiveTvProgram).Name },
ChannelIds = new[] { channel.Id.ToString("N") }, ChannelIds = new[] { channel.Id.ToString("N") },
@ -1845,7 +1843,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
Limit = 1, Limit = 1,
SortBy = new[] { "StartDate" } SortBy = new[] { "StartDate" }
}).Items.Cast<LiveTvProgram>(); }, new string[] { }).Cast<LiveTvProgram>();
var currentProgram = programs.FirstOrDefault(); var currentProgram = programs.FirstOrDefault();