diff options
Diffstat (limited to 'MediaBrowser.Controller/Entities/BaseItem.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index ee562d8b4..1e46aa9e5 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -359,7 +359,7 @@ namespace MediaBrowser.Controller.Entities { get { - if (!string.IsNullOrEmpty(ForcedSortName)) + if (!string.IsNullOrWhiteSpace(ForcedSortName)) { return ForcedSortName; } @@ -379,21 +379,19 @@ namespace MediaBrowser.Controller.Entities public string GetInternalMetadataPath() { - return GetInternalMetadataPath(ConfigurationManager.ApplicationPaths.InternalMetadataPath); + var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath; + + return GetInternalMetadataPath(basePath); } protected virtual string GetInternalMetadataPath(string basePath) { var idString = Id.ToString("N"); - return System.IO.Path.Combine(basePath, idString.Substring(0, 2), idString); - } - - public static string GetInternalMetadataPathForId(Guid id) - { - var idString = id.ToString("N"); - - var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath; + if (ConfigurationManager.Configuration.EnableLibraryMetadataSubFolder) + { + basePath = System.IO.Path.Combine(basePath, "library"); + } return System.IO.Path.Combine(basePath, idString.Substring(0, 2), idString); } @@ -692,7 +690,7 @@ namespace MediaBrowser.Controller.Entities var requiresSave = false; - if (IsFolder || Parent != null) + if (SupportsOwnedItems) { try { @@ -724,6 +722,12 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + protected virtual bool SupportsOwnedItems + { + get { return IsFolder || Parent != null; } + } + /// <summary> /// Refreshes owned items such as trailers, theme videos, special features, etc. /// Returns true or false indicating if changes were found. @@ -889,11 +893,24 @@ namespace MediaBrowser.Controller.Entities get { return null; } } + private string _userDataKey; /// <summary> /// Gets the user data key. /// </summary> /// <returns>System.String.</returns> - public virtual string GetUserDataKey() + public string GetUserDataKey() + { + if (string.IsNullOrWhiteSpace(_userDataKey)) + { + var key = CreateUserDataKey(); + _userDataKey = key; + return key; + } + + return _userDataKey; + } + + protected virtual string CreateUserDataKey() { return Id.ToString(); } @@ -905,6 +922,12 @@ namespace MediaBrowser.Controller.Entities return current.IsInMixedFolder == newItem.IsInMixedFolder; } + public void AfterMetadataRefresh() + { + _sortName = null; + _userDataKey = null; + } + /// <summary> /// Gets the preferred metadata language. /// </summary> @@ -1146,7 +1169,7 @@ namespace MediaBrowser.Controller.Entities if (!string.IsNullOrWhiteSpace(info.ItemName) && !string.IsNullOrWhiteSpace(info.ItemType)) { - return LibraryManager.RootFolder.RecursiveChildren.FirstOrDefault(i => + return LibraryManager.RootFolder.GetRecursiveChildren(i => { if (string.Equals(i.Name, info.ItemName, StringComparison.OrdinalIgnoreCase)) { @@ -1164,7 +1187,8 @@ namespace MediaBrowser.Controller.Entities } return false; - }); + + }).FirstOrDefault(); } return null; @@ -1458,7 +1482,7 @@ namespace MediaBrowser.Controller.Entities currentFile.Attributes &= ~FileAttributes.Hidden; } - currentFile.Delete(); + FileSystem.DeleteFile(currentFile.FullName); } return UpdateToRepository(ItemUpdateType.ImageUpdate, CancellationToken.None); @@ -1703,6 +1727,9 @@ namespace MediaBrowser.Controller.Entities /// </summary> public virtual bool BeforeMetadataRefresh() { + _userDataKey = null; + _sortName = null; + var hasChanges = false; if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path)) |
