fix library changed

This commit is contained in:
Luke Pulverenti 2015-04-10 10:49:03 -04:00
parent 4f7e8fee24
commit fbbab13b31
5 changed files with 31 additions and 30 deletions

View File

@ -104,7 +104,7 @@ namespace MediaBrowser.Controller.Channels
public override bool IsVisibleStandalone(User user) public override bool IsVisibleStandalone(User user)
{ {
return base.IsVisibleStandalone(user) && ChannelVideoItem.IsChannelVisible(this, user); return IsVisibleStandaloneInternal(user, false) && ChannelVideoItem.IsChannelVisible(this, user);
} }
} }
} }

View File

@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Channels
public override bool IsVisibleStandalone(User user) public override bool IsVisibleStandalone(User user)
{ {
return base.IsVisibleStandalone(user) && ChannelVideoItem.IsChannelVisible(this, user); return IsVisibleStandaloneInternal(user, false) && ChannelVideoItem.IsChannelVisible(this, user);
} }
} }
} }

View File

@ -133,7 +133,7 @@ namespace MediaBrowser.Controller.Channels
public override bool IsVisibleStandalone(User user) public override bool IsVisibleStandalone(User user)
{ {
return base.IsVisibleStandalone(user) && IsChannelVisible(this, user); return IsVisibleStandaloneInternal(user, false) && IsChannelVisible(this, user);
} }
internal static bool IsChannelVisible(IChannelItem item, User user) internal static bool IsChannelVisible(IChannelItem item, User user)

View File

@ -1143,6 +1143,11 @@ namespace MediaBrowser.Controller.Entities
} }
public virtual bool IsVisibleStandalone(User user) public virtual bool IsVisibleStandalone(User user)
{
return IsVisibleStandaloneInternal(user, true);
}
protected bool IsVisibleStandaloneInternal(User user, bool checkFolders)
{ {
if (!IsVisible(user)) if (!IsVisible(user))
{ {
@ -1154,6 +1159,8 @@ namespace MediaBrowser.Controller.Entities
return false; return false;
} }
if (checkFolders)
{
var topParent = Parents.LastOrDefault() ?? this; var topParent = Parents.LastOrDefault() ?? this;
if (string.IsNullOrWhiteSpace(topParent.Path)) if (string.IsNullOrWhiteSpace(topParent.Path))
@ -1161,10 +1168,16 @@ namespace MediaBrowser.Controller.Entities
return true; return true;
} }
var folders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList(); var userCollectionFolders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList();
var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList(); var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id);
return itemCollectionFolders.Any(folders.Contains); if (!itemCollectionFolders.Any(userCollectionFolders.Contains))
{
return false;
}
}
return true;
} }
/// <summary> /// <summary>
@ -1669,7 +1682,7 @@ namespace MediaBrowser.Controller.Entities
else else
{ {
existing.DateModified = FileSystem.GetLastWriteTimeUtc(newImage); existing.DateModified = FileSystem.GetLastWriteTimeUtc(newImage);
existing.Length = ((FileInfo) newImage).Length; existing.Length = ((FileInfo)newImage).Length;
} }
} }

View File

@ -243,19 +243,17 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{ {
var user = _userManager.GetUserById(userId); var user = _userManager.GetUserById(userId);
var collections = user.RootFolder.GetChildren(user, true).ToList();
return new LibraryUpdateInfo return new LibraryUpdateInfo
{ {
ItemsAdded = itemsAdded.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections)).Select(i => i.Id.ToString("N")).Distinct().ToList(), ItemsAdded = itemsAdded.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList(),
ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections)).Select(i => i.Id.ToString("N")).Distinct().ToList(), ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList(),
ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, true)).Select(i => i.Id.ToString("N")).Distinct().ToList(), ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, true)).Select(i => i.Id.ToString("N")).Distinct().ToList(),
FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections)).Select(i => i.Id.ToString("N")).Distinct().ToList(), FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList(),
FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections)).Select(i => i.Id.ToString("N")).Distinct().ToList() FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList()
}; };
} }
@ -265,10 +263,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="user">The user.</param> /// <param name="user">The user.</param>
/// <param name="collections">The collections.</param>
/// <param name="includeIfNotFound">if set to <c>true</c> [include if not found].</param> /// <param name="includeIfNotFound">if set to <c>true</c> [include if not found].</param>
/// <returns>IEnumerable{``0}.</returns> /// <returns>IEnumerable{``0}.</returns>
private IEnumerable<T> TranslatePhysicalItemToUserLibrary<T>(T item, User user, IEnumerable<BaseItem> collections, bool includeIfNotFound = false) private IEnumerable<T> TranslatePhysicalItemToUserLibrary<T>(T item, User user, bool includeIfNotFound = false)
where T : BaseItem where T : BaseItem
{ {
// If the physical root changed, return the user root // If the physical root changed, return the user root
@ -277,15 +274,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
return new[] { user.RootFolder as T }; return new[] { user.RootFolder as T };
} }
// Need to find what user collection folder this belongs to
if (item.Parent is AggregateFolder)
{
if (item.LocationType == LocationType.FileSystem)
{
return collections.Where(i => i.PhysicalLocations.Contains(item.Path)).Cast<T>();
}
}
// Return it only if it's in the user's library // Return it only if it's in the user's library
if (includeIfNotFound || item.IsVisibleStandalone(user)) if (includeIfNotFound || item.IsVisibleStandalone(user))
{ {