fix library changed
This commit is contained in:
parent
4f7e8fee24
commit
fbbab13b31
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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,17 +1159,25 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var topParent = Parents.LastOrDefault() ?? this;
|
if (checkFolders)
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(topParent.Path))
|
|
||||||
{
|
{
|
||||||
return true;
|
var topParent = Parents.LastOrDefault() ?? this;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(topParent.Path))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var userCollectionFolders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList();
|
||||||
|
var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id);
|
||||||
|
|
||||||
|
if (!itemCollectionFolders.Any(userCollectionFolders.Contains))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var folders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList();
|
return true;
|
||||||
var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList();
|
|
||||||
|
|
||||||
return itemCollectionFolders.Any(folders.Contains);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user