aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-07-06 23:08:52 +0200
committerGitHub <noreply@github.com>2019-07-06 23:08:52 +0200
commit82f041d050f998d20818efff063b6000dfcbf5d2 (patch)
tree3be5cf1a79180c57a5381e26f60d61088a27b49e /MediaBrowser.Controller/Entities
parent4f17ed961e2756e0c65b1bb0246e7f62a5f44a8a (diff)
parentba551b48e1e1c80192e10b1bb340d974c6b6dee2 (diff)
Merge branch 'master' into release-10.3.z
Diffstat (limited to 'MediaBrowser.Controller/Entities')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItemExtensions.cs30
-rw-r--r--MediaBrowser.Controller/Entities/User.cs10
-rw-r--r--MediaBrowser.Controller/Entities/UserView.cs5
-rw-r--r--MediaBrowser.Controller/Entities/UserViewBuilder.cs12
4 files changed, 38 insertions, 19 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs
index 9c955a724..815239be2 100644
--- a/MediaBrowser.Controller/Entities/BaseItemExtensions.cs
+++ b/MediaBrowser.Controller/Entities/BaseItemExtensions.cs
@@ -64,21 +64,31 @@ namespace MediaBrowser.Controller.Entities
where T : BaseItem
where TU : BaseItem
{
- var sourceProps = typeof(T).GetProperties().Where(x => x.CanRead).ToList();
- var destProps = typeof(TU).GetProperties()
- .Where(x => x.CanWrite)
- .ToList();
+ var destProps = typeof(TU).GetProperties().Where(x => x.CanWrite).ToList();
- foreach (var sourceProp in sourceProps)
+ foreach (var sourceProp in typeof(T).GetProperties())
{
- if (destProps.Any(x => x.Name == sourceProp.Name))
+ // We should be able to write to the property
+ // for both the source and destination type
+ // This is only false when the derived type hides the base member
+ // (which we shouldn't copy anyway)
+ if (!sourceProp.CanRead || !sourceProp.CanWrite)
{
- var p = destProps.First(x => x.Name == sourceProp.Name);
- p.SetValue(dest, sourceProp.GetValue(source, null), null);
+ continue;
}
- }
+ var v = sourceProp.GetValue(source);
+ if (v == null)
+ {
+ continue;
+ }
+ var p = destProps.Find(x => x.Name == sourceProp.Name);
+ if (p != null)
+ {
+ p.SetValue(dest, v);
+ }
+ }
}
/// <summary>
@@ -93,7 +103,5 @@ namespace MediaBrowser.Controller.Entities
source.DeepCopy(dest);
return dest;
}
-
-
}
}
diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs
index 0d5f508dd..9952ba418 100644
--- a/MediaBrowser.Controller/Entities/User.cs
+++ b/MediaBrowser.Controller/Entities/User.cs
@@ -228,7 +228,15 @@ namespace MediaBrowser.Controller.Entities
return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName);
}
- return System.IO.Path.Combine(parentPath, Id.ToString("N"));
+ // TODO: Remove idPath and just use usernamePath for future releases
+ var usernamePath = System.IO.Path.Combine(parentPath, username);
+ var idPath = System.IO.Path.Combine(parentPath, Id.ToString("N"));
+ if (!Directory.Exists(usernamePath) && Directory.Exists(idPath))
+ {
+ Directory.Move(idPath, usernamePath);
+ }
+
+ return usernamePath;
}
public bool IsParentalScheduleAllowed()
diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs
index 3e2191376..4a6d32dce 100644
--- a/MediaBrowser.Controller/Entities/UserView.cs
+++ b/MediaBrowser.Controller/Entities/UserView.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using MediaBrowser.Controller.Playlists;
using MediaBrowser.Controller.TV;
using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Serialization;
@@ -17,7 +16,6 @@ namespace MediaBrowser.Controller.Entities
public Guid? UserId { get; set; }
public static ITVSeriesManager TVSeriesManager;
- public static IPlaylistManager PlaylistManager;
[IgnoreDataMember]
public string CollectionType => ViewType;
@@ -38,6 +36,7 @@ namespace MediaBrowser.Controller.Entities
{
list.Add(Id);
}
+
return list;
}
@@ -65,7 +64,7 @@ namespace MediaBrowser.Controller.Entities
parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent;
}
- return new UserViewBuilder(UserViewManager, LibraryManager, Logger, UserDataManager, TVSeriesManager, ConfigurationManager, PlaylistManager)
+ return new UserViewBuilder(UserViewManager, LibraryManager, Logger, UserDataManager, TVSeriesManager, ConfigurationManager)
.GetUserItems(parent, this, CollectionType, query);
}
diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
index 683218a9e..e483c8f34 100644
--- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs
+++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
@@ -5,7 +5,6 @@ using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Playlists;
using MediaBrowser.Controller.TV;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
@@ -21,9 +20,14 @@ namespace MediaBrowser.Controller.Entities
private readonly IUserDataManager _userDataManager;
private readonly ITVSeriesManager _tvSeriesManager;
private readonly IServerConfigurationManager _config;
- private readonly IPlaylistManager _playlistManager;
- public UserViewBuilder(IUserViewManager userViewManager, ILibraryManager libraryManager, ILogger logger, IUserDataManager userDataManager, ITVSeriesManager tvSeriesManager, IServerConfigurationManager config, IPlaylistManager playlistManager)
+ public UserViewBuilder(
+ IUserViewManager userViewManager,
+ ILibraryManager libraryManager,
+ ILogger logger,
+ IUserDataManager userDataManager,
+ ITVSeriesManager tvSeriesManager,
+ IServerConfigurationManager config)
{
_userViewManager = userViewManager;
_libraryManager = libraryManager;
@@ -31,7 +35,6 @@ namespace MediaBrowser.Controller.Entities
_userDataManager = userDataManager;
_tvSeriesManager = tvSeriesManager;
_config = config;
- _playlistManager = playlistManager;
}
public QueryResult<BaseItem> GetUserItems(Folder queryParent, Folder displayParent, string viewType, InternalItemsQuery query)
@@ -110,6 +113,7 @@ namespace MediaBrowser.Controller.Entities
{
return GetResult(GetMediaFolders(user).OfType<Folder>().SelectMany(i => i.GetChildren(user, true)), queryParent, query);
}
+
return queryParent.GetItems(query);
}
}