mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 14:28:46 +01:00
easier user library setup
This commit is contained in:
@@ -277,6 +277,19 @@ namespace MediaBrowser.Controller.Entities
|
||||
get { return GetRecursiveChildren(); }
|
||||
}
|
||||
|
||||
public override bool IsVisible(User user)
|
||||
{
|
||||
if (this is ICollectionFolder)
|
||||
{
|
||||
if (user.Configuration.BlockedMediaFolders.Contains(Name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return base.IsVisible(user);
|
||||
}
|
||||
|
||||
private List<BaseItem> LoadChildrenInternal()
|
||||
{
|
||||
return LoadChildren().ToList();
|
||||
@@ -762,15 +775,15 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
list.Add(child);
|
||||
}
|
||||
}
|
||||
|
||||
if (recursive && child.IsFolder)
|
||||
{
|
||||
var folder = (Folder)child;
|
||||
|
||||
if (folder.AddChildrenToList(user, includeLinkedChildren, list, true, filter))
|
||||
if (recursive && child.IsFolder)
|
||||
{
|
||||
hasLinkedChildren = true;
|
||||
var folder = (Folder)child;
|
||||
|
||||
if (folder.AddChildrenToList(user, includeLinkedChildren, list, true, filter))
|
||||
{
|
||||
hasLinkedChildren = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,35 +19,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
public static IUserManager UserManager { get; set; }
|
||||
public static IXmlSerializer XmlSerializer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the root folder path.
|
||||
/// </summary>
|
||||
/// <value>The root folder path.</value>
|
||||
[IgnoreDataMember]
|
||||
public string RootFolderPath
|
||||
{
|
||||
get
|
||||
{
|
||||
var path = Configuration.UseCustomLibrary ? GetRootFolderPath(Name) : ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;
|
||||
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the root folder path based on a given username
|
||||
/// </summary>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
private string GetRootFolderPath(string username)
|
||||
{
|
||||
var safeFolderName = FileSystem.GetValidFilename(username);
|
||||
|
||||
return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.RootFolderPath, safeFolderName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the password.
|
||||
/// </summary>
|
||||
@@ -97,24 +68,16 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The _root folder
|
||||
/// </summary>
|
||||
private UserRootFolder _rootFolder;
|
||||
/// <summary>
|
||||
/// Gets the root folder.
|
||||
/// </summary>
|
||||
/// <value>The root folder.</value>
|
||||
[IgnoreDataMember]
|
||||
public UserRootFolder RootFolder
|
||||
public Folder RootFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rootFolder ?? (LibraryManager.GetUserRootFolder(RootFolderPath));
|
||||
}
|
||||
private set
|
||||
{
|
||||
_rootFolder = value;
|
||||
return LibraryManager.GetUserRootFolder();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,22 +128,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the root media folder
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task ValidateMediaLibrary(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
Logger.Info("Validating media library for {0}", Name);
|
||||
await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await RootFolder.ValidateChildren(progress, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renames the user.
|
||||
/// </summary>
|
||||
@@ -215,29 +162,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
Directory.CreateDirectory(newConfigDirectory);
|
||||
}
|
||||
|
||||
var customLibraryPath = GetRootFolderPath(Name);
|
||||
|
||||
// Move the root folder path if using a custom library
|
||||
if (Directory.Exists(customLibraryPath))
|
||||
{
|
||||
var newRootFolderPath = GetRootFolderPath(newName);
|
||||
if (Directory.Exists(newRootFolderPath))
|
||||
{
|
||||
Directory.Delete(newRootFolderPath, true);
|
||||
}
|
||||
Directory.Move(customLibraryPath, newRootFolderPath);
|
||||
}
|
||||
}
|
||||
|
||||
Name = newName;
|
||||
|
||||
// Force these to be lazy loaded again
|
||||
RootFolder = null;
|
||||
|
||||
// Kick off a task to validate the media library
|
||||
Task.Run(() => ValidateMediaLibrary(new Progress<double>(), CancellationToken.None));
|
||||
|
||||
return RefreshMetadata(new MetadataRefreshOptions
|
||||
{
|
||||
ReplaceAllMetadata = true,
|
||||
@@ -318,16 +246,8 @@ namespace MediaBrowser.Controller.Entities
|
||||
throw new ArgumentNullException("config");
|
||||
}
|
||||
|
||||
var customLibraryChanged = config.UseCustomLibrary != Configuration.UseCustomLibrary;
|
||||
|
||||
Configuration = config;
|
||||
SaveConfiguration(serializer);
|
||||
|
||||
// Force these to be lazy loaded again
|
||||
if (customLibraryChanged)
|
||||
{
|
||||
RootFolder = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
if (string.Equals("default", Name, System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Name = "Default Media Library";
|
||||
Name = "Media Folders";
|
||||
hasChanges = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,9 +202,8 @@ namespace MediaBrowser.Controller.Library
|
||||
/// <summary>
|
||||
/// Gets the user root folder.
|
||||
/// </summary>
|
||||
/// <param name="userRootPath">The user root path.</param>
|
||||
/// <returns>UserRootFolder.</returns>
|
||||
UserRootFolder GetUserRootFolder(string userRootPath);
|
||||
Folder GetUserRootFolder();
|
||||
|
||||
/// <summary>
|
||||
/// Creates the item.
|
||||
|
||||
Reference in New Issue
Block a user