The Free Software Media System - Server Backend & API
use conditional caching on some json responses
Luke Pulverenti351cfef7a70e
diff --git a/MediaBrowser.Api/AlbumsService.cs b/MediaBrowser.Api/AlbumsService.csindex b8a830711a..5787ad180c 100644--- a/MediaBrowser.Api/AlbumsService.cs+++ b/MediaBrowser.Api/AlbumsService.cs@@ -59,7 +59,7 @@ namespace MediaBrowser.Apirequest, item => item is MusicAlbum,GetAlbumSimilarityScore);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.csindex 556f3b57d5..2dd1c77e1e 100644--- a/MediaBrowser.Api/BaseApiService.cs+++ b/MediaBrowser.Api/BaseApiService.cs@@ -21,7 +21,7 @@ namespace MediaBrowser.Api/// </summary>/// <value>The logger.</value>public ILogger Logger { get; set; }-+/// <summary>/// Gets or sets the HTTP result factory./// </summary>@@ -58,15 +58,26 @@ namespace MediaBrowser.Api/// <param name="cacheKey">The cache key.</param>/// <param name="lastDateModified">The last date modified.</param>/// <param name="cacheDuration">Duration of the cache.</param>- /// <param name="factoryFn">The factory fn.</param>+ /// <param name="factoryFn">The factory function.</param>/// <returns>System.Object.</returns>- /// <exception cref="System.ArgumentNullException">cacheKey</exception>- protected object ToOptimizedResultUsingCache<T>(Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn)- where T : class+ protected object ToOptimizedResultUsingCache<T>(Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn)+ where T : class{return ResultFactory.GetOptimizedResultUsingCache(Request, cacheKey, lastDateModified, cacheDuration, factoryFn);}+ /// <summary>+ /// To the optimized serialized result using cache.+ /// </summary>+ /// <typeparam name="T"></typeparam>+ /// <param name="result">The result.</param>+ /// <returns>System.Object.</returns>+ protected object ToOptimizedSerializedResultUsingCache<T>(T result)+ where T : class+ {+ return ResultFactory.GetOptimizedSerializedResultUsingCache(Request, result);+ }+/// <summary>/// To the cached result./// </summary>diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.csindex 206d0c265f..b2a5fa7a73 100644--- a/MediaBrowser.Api/ConfigurationService.cs+++ b/MediaBrowser.Api/ConfigurationService.cs@@ -99,12 +99,12 @@ namespace MediaBrowser.Apipublic object Get(GetDefaultMetadataOptions request){- return ToOptimizedResult(new MetadataOptions());+ return ToOptimizedSerializedResultUsingCache(new MetadataOptions());}public object Get(GetMetadataPlugins request){- return ToOptimizedResult(_providerManager.GetAllMetadataPlugins().ToList());+ return ToOptimizedSerializedResultUsingCache(_providerManager.GetAllMetadataPlugins().ToList());}}}diff --git a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.csindex 75ef7e54e4..6a91897f2f 100644--- a/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs+++ b/MediaBrowser.Api/DefaultTheme/DefaultThemeService.cs@@ -215,7 +215,7 @@ namespace MediaBrowser.Api.DefaultTheme.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToList();- return ToOptimizedResult(view);+ return ToOptimizedSerializedResultUsingCache(view);}public object Get(GetGamesView request)@@ -268,7 +268,7 @@ namespace MediaBrowser.Api.DefaultTheme.Take(1).ToList();- return ToOptimizedResult(view);+ return ToOptimizedSerializedResultUsingCache(view);}public object Get(GetTvView request)@@ -394,7 +394,7 @@ namespace MediaBrowser.Api.DefaultTheme.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToList();- return ToOptimizedResult(view);+ return ToOptimizedSerializedResultUsingCache(view);}public object Get(GetMovieView request)@@ -569,7 +569,7 @@ namespace MediaBrowser.Api.DefaultTheme.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToList();- return ToOptimizedResult(view);+ return ToOptimizedSerializedResultUsingCache(view);}private IEnumerable<BaseItem> FilterItemsForBackdropDisplay(IEnumerable<BaseItem> items)diff --git a/MediaBrowser.Api/DisplayPreferencesService.cs b/MediaBrowser.Api/DisplayPreferencesService.csindex 39b335316b..f22dc9e39e 100644--- a/MediaBrowser.Api/DisplayPreferencesService.cs+++ b/MediaBrowser.Api/DisplayPreferencesService.cs@@ -88,7 +88,7 @@ namespace MediaBrowser.Apivar result = _displayPreferencesManager.GetDisplayPreferences(displayPreferencesId, request.UserId, request.Client);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.csindex aac7085207..cb104072bd 100644--- a/MediaBrowser.Api/EnvironmentService.cs+++ b/MediaBrowser.Api/EnvironmentService.cs@@ -135,10 +135,10 @@ namespace MediaBrowser.Apiif (path.StartsWith(networkPrefix, StringComparison.OrdinalIgnoreCase) && path.LastIndexOf(UncSeparator) == 1){- return ToOptimizedResult(GetNetworkShares(path).OrderBy(i => i.Path).ToList());+ return ToOptimizedSerializedResultUsingCache(GetNetworkShares(path).OrderBy(i => i.Path).ToList());}- return ToOptimizedResult(GetFileSystemEntries(request).OrderBy(i => i.Path).ToList());+ return ToOptimizedSerializedResultUsingCache(GetFileSystemEntries(request).OrderBy(i => i.Path).ToList());}public object Get(GetNetworkShares request)@@ -147,7 +147,7 @@ namespace MediaBrowser.Apivar shares = GetNetworkShares(path).OrderBy(i => i.Path).ToList();- return ToOptimizedResult(shares);+ return ToOptimizedSerializedResultUsingCache(shares);}/// <summary>@@ -159,7 +159,7 @@ namespace MediaBrowser.Api{var result = GetDrives().ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -189,7 +189,7 @@ namespace MediaBrowser.Api.OrderBy(i => i.Path).ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/GamesService.cs b/MediaBrowser.Api/GamesService.csindex ef4fed3d36..d3b7cbe41b 100644--- a/MediaBrowser.Api/GamesService.cs+++ b/MediaBrowser.Api/GamesService.cs@@ -113,7 +113,7 @@ namespace MediaBrowser.Api.Select(i => GetSummary(i, user)).ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}private static readonly CultureInfo UsCulture = new CultureInfo("en-US");@@ -134,7 +134,7 @@ namespace MediaBrowser.Api}).ToList();- return ToOptimizedResult(lookup);+ return ToOptimizedSerializedResultUsingCache(lookup);}/// <summary>@@ -182,7 +182,7 @@ namespace MediaBrowser.Apirequest, item => item is Game,SimilarItemsHelper.GetSimiliarityScore);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}}}diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.csindex 728ceeea96..514e856550 100644--- a/MediaBrowser.Api/Images/ImageService.cs+++ b/MediaBrowser.Api/Images/ImageService.cs@@ -361,14 +361,14 @@ namespace MediaBrowser.Api.Imagesvar result = GetItemImageInfos(item);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetItemByNameImageInfos request){var result = GetItemByNameImageInfos(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.csindex 37bf0c1cae..deba146e8c 100644--- a/MediaBrowser.Api/Images/RemoteImageService.cs+++ b/MediaBrowser.Api/Images/RemoteImageService.cs@@ -176,7 +176,7 @@ namespace MediaBrowser.Api.Imagesvar result = GetImageProviders(item);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetItemByNameRemoteImageProviders request)@@ -188,7 +188,7 @@ namespace MediaBrowser.Api.Imagesvar result = GetImageProviders(item);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}private List<ImageProviderInfo> GetImageProviders(BaseItem item)@@ -202,7 +202,7 @@ namespace MediaBrowser.Api.Imagesvar result = GetRemoteImageResult(item, request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetItemByNameRemoteImages request)diff --git a/MediaBrowser.Api/InstantMixService.cs b/MediaBrowser.Api/InstantMixService.csindex c11f38123d..624137677c 100644--- a/MediaBrowser.Api/InstantMixService.cs+++ b/MediaBrowser.Api/InstantMixService.cs@@ -57,7 +57,7 @@ namespace MediaBrowser.Apivar result = GetInstantMixResult(request, item.Genres);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetInstantMixFromAlbum request)@@ -73,7 +73,7 @@ namespace MediaBrowser.Apivar result = GetInstantMixResult(request, genres);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetInstantMixFromMusicGenre request)@@ -82,7 +82,7 @@ namespace MediaBrowser.Apivar result = GetInstantMixResult(request, new[] { genre.Name });- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetInstantMixFromArtist request)@@ -99,7 +99,7 @@ namespace MediaBrowser.Apivar result = GetInstantMixResult(request, genres);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}private ItemsResult GetInstantMixResult(BaseGetSimilarItems request, IEnumerable<string> genres)diff --git a/MediaBrowser.Api/Library/FileOrganizationService.cs b/MediaBrowser.Api/Library/FileOrganizationService.csindex 44fad6a859..01531a7ae6 100644--- a/MediaBrowser.Api/Library/FileOrganizationService.cs+++ b/MediaBrowser.Api/Library/FileOrganizationService.cs@@ -95,7 +95,7 @@ namespace MediaBrowser.Api.LibraryStartIndex = request.StartIndex});- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public void Delete(DeleteOriginalFile request)diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.csindex f3d5824da2..79b2651d5a 100644--- a/MediaBrowser.Api/Library/LibraryService.cs+++ b/MediaBrowser.Api/Library/LibraryService.cs@@ -77,7 +77,7 @@ namespace MediaBrowser.Api.Library{try{- return c.ResolveArgs.PhysicalLocations;+ return c.PhysicalLocations;}catch (Exception ex){@@ -90,7 +90,7 @@ namespace MediaBrowser.Api.Library}).ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.csindex 8ea472da30..f08d79c0db 100644--- a/MediaBrowser.Api/Library/LibraryStructureService.cs+++ b/MediaBrowser.Api/Library/LibraryStructureService.cs@@ -251,7 +251,7 @@ namespace MediaBrowser.Api.Library{var result = _libraryManager.GetDefaultVirtualFolders().OrderBy(i => i.Name).ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}else{@@ -259,7 +259,7 @@ namespace MediaBrowser.Api.Libraryvar result = _libraryManager.GetVirtualFolders(user).OrderBy(i => i.Name).ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}}diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.csindex d9442b63d5..584bbf9a1a 100644--- a/MediaBrowser.Api/LibraryService.cs+++ b/MediaBrowser.Api/LibraryService.cs@@ -284,7 +284,7 @@ namespace MediaBrowser.Api{var result = GetAncestors(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -337,7 +337,7 @@ namespace MediaBrowser.Apitry{return i.LocationType == LocationType.FileSystem &&- i.ResolveArgs.PhysicalLocations.Contains(item.Path);+ i.PhysicalLocations.Contains(item.Path);}catch (Exception ex){@@ -360,7 +360,7 @@ namespace MediaBrowser.Api{var result = GetCriticReviews(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -405,7 +405,7 @@ namespace MediaBrowser.ApiUniqueTypes = items.Select(i => i.GetClientTypeName()).Distinct().ToList()};- return ToOptimizedResult(counts);+ return ToOptimizedSerializedResultUsingCache(counts);}private IEnumerable<T> FilterItems<T>(IEnumerable<T> items, GetItemCounts request, Guid userId)@@ -552,7 +552,7 @@ namespace MediaBrowser.Api});- return ToOptimizedResult(new AllThemeMediaResult+ return ToOptimizedSerializedResultUsingCache(new AllThemeMediaResult{ThemeSongsResult = themeSongs,ThemeVideosResult = themeVideos,@@ -570,7 +570,7 @@ namespace MediaBrowser.Api{var result = GetThemeSongs(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}private ThemeMediaResult GetThemeSongs(GetThemeSongs request)@@ -638,7 +638,7 @@ namespace MediaBrowser.Api{var result = GetThemeVideos(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public ThemeMediaResult GetThemeVideos(GetThemeVideos request)@@ -748,7 +748,7 @@ namespace MediaBrowser.Api}).ToList();- return ToOptimizedResult(lookup);+ return ToOptimizedSerializedResultUsingCache(lookup);}public ThemeMediaResult GetSoundtrackSongs(string id, Guid? userId, bool inheritFromParent)diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex 9d827226c9..569e4b52b9 100644--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs@@ -304,7 +304,7 @@ namespace MediaBrowser.Api.LiveTv{var info = _liveTvManager.GetLiveTvInfo(CancellationToken.None).Result;- return ToOptimizedResult(info);+ return ToOptimizedSerializedResultUsingCache(info);}public object Get(GetChannels request)@@ -318,7 +318,7 @@ namespace MediaBrowser.Api.LiveTv}, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetChannel request)@@ -327,7 +327,7 @@ namespace MediaBrowser.Api.LiveTvvar result = _liveTvManager.GetChannel(request.Id, CancellationToken.None, user).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetPrograms request)@@ -360,7 +360,7 @@ namespace MediaBrowser.Api.LiveTvvar result = _liveTvManager.GetPrograms(query, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetRecommendedPrograms request)@@ -375,7 +375,7 @@ namespace MediaBrowser.Api.LiveTvvar result = _liveTvManager.GetRecommendedPrograms(query, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Post(GetPrograms request)@@ -398,7 +398,7 @@ namespace MediaBrowser.Api.LiveTv}, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetRecording request)@@ -407,14 +407,14 @@ namespace MediaBrowser.Api.LiveTvvar result = _liveTvManager.GetRecording(request.Id, CancellationToken.None, user).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetTimer request){var result = _liveTvManager.GetTimer(request.Id, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetTimers request)@@ -426,7 +426,7 @@ namespace MediaBrowser.Api.LiveTv}, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public void Delete(DeleteRecording request)@@ -465,14 +465,14 @@ namespace MediaBrowser.Api.LiveTv}, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetSeriesTimer request){var result = _liveTvManager.GetSeriesTimer(request.Id, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public void Delete(CancelSeriesTimer request)@@ -499,13 +499,13 @@ namespace MediaBrowser.Api.LiveTv{var result = _liveTvManager.GetNewTimerDefaults(CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}else{var result = _liveTvManager.GetNewTimerDefaults(request.ProgramId, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}}@@ -515,7 +515,7 @@ namespace MediaBrowser.Api.LiveTvvar result = _liveTvManager.GetProgram(request.Id, CancellationToken.None, user).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public void Post(CreateSeriesTimer request)@@ -544,7 +544,7 @@ namespace MediaBrowser.Api.LiveTv}, CancellationToken.None).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public object Get(GetRecordingGroup request)@@ -556,7 +556,7 @@ namespace MediaBrowser.Api.LiveTvvar group = result.Items.FirstOrDefault(i => string.Equals(i.Id, request.Id, StringComparison.OrdinalIgnoreCase));- return ToOptimizedResult(group);+ return ToOptimizedSerializedResultUsingCache(group);}public object Get(GetGuideInfo request)diff --git a/MediaBrowser.Api/LocalizationService.cs b/MediaBrowser.Api/LocalizationService.csindex 54ac8591ea..b3f6cbd976 100644--- a/MediaBrowser.Api/LocalizationService.cs+++ b/MediaBrowser.Api/LocalizationService.cs@@ -62,7 +62,7 @@ namespace MediaBrowser.Api{var result = _localization.GetParentalRatings().ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -74,7 +74,7 @@ namespace MediaBrowser.Api{var result = _localization.GetCountries().ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -86,7 +86,7 @@ namespace MediaBrowser.Api{var result = _localization.GetCultures().ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}}diff --git a/MediaBrowser.Api/MoviesService.cs b/MediaBrowser.Api/MoviesService.csindex 1b36ec8915..2a99bca8b0 100644--- a/MediaBrowser.Api/MoviesService.cs+++ b/MediaBrowser.Api/MoviesService.cs@@ -76,7 +76,7 @@ namespace MediaBrowser.Apirequest, item => item is Movie || (item is Trailer && request.IncludeTrailers),SimilarItemsHelper.GetSimiliarityScore);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}}}diff --git a/MediaBrowser.Api/NewsService.cs b/MediaBrowser.Api/NewsService.csindex efafc9d3f3..99a4d4fa7e 100644--- a/MediaBrowser.Api/NewsService.cs+++ b/MediaBrowser.Api/NewsService.cs@@ -42,7 +42,7 @@ namespace MediaBrowser.Api});- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}}}diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.csindex de9c89666c..e66f432df8 100644--- a/MediaBrowser.Api/PluginService.cs+++ b/MediaBrowser.Api/PluginService.cs@@ -166,7 +166,7 @@ namespace MediaBrowser.Api{var result = _appHost.Plugins.OrderBy(p => p.Name).Select(p => p.GetPluginInfo()).ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -199,7 +199,7 @@ namespace MediaBrowser.ApiLegacyKey = _securityManager.LegacyKey};- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.csindex 8626709a3b..330d7c46f3 100644--- a/MediaBrowser.Api/SearchService.cs+++ b/MediaBrowser.Api/SearchService.cs@@ -110,7 +110,7 @@ namespace MediaBrowser.Api{var result = GetSearchHintsAsync(request).Result;- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/TrailersService.cs b/MediaBrowser.Api/TrailersService.csindex 7d137646cc..ca465b5e32 100644--- a/MediaBrowser.Api/TrailersService.cs+++ b/MediaBrowser.Api/TrailersService.cs@@ -69,7 +69,7 @@ namespace MediaBrowser.Apirequest, item => item is Movie || item is Trailer,SimilarItemsHelper.GetSimiliarityScore);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}}}diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.csindex 9521f82cce..629f9b2333 100644--- a/MediaBrowser.Api/TvShowsService.cs+++ b/MediaBrowser.Api/TvShowsService.cs@@ -183,7 +183,7 @@ namespace MediaBrowser.Apirequest, item => item is Series,SimilarItemsHelper.GetSimiliarityScore);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -210,7 +210,7 @@ namespace MediaBrowser.ApiItems = returnItems};- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}public IEnumerable<Episode> GetNextUpEpisodes(GetNextUpEpisodes request)diff --git a/MediaBrowser.Api/UserLibrary/GameGenresService.cs b/MediaBrowser.Api/UserLibrary/GameGenresService.csindex 79ee27df62..d282ee091d 100644--- a/MediaBrowser.Api/UserLibrary/GameGenresService.cs+++ b/MediaBrowser.Api/UserLibrary/GameGenresService.cs@@ -57,7 +57,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetItem(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -91,7 +91,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetResult(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/UserLibrary/GenresService.cs b/MediaBrowser.Api/UserLibrary/GenresService.csindex ded9544f8e..092c638822 100644--- a/MediaBrowser.Api/UserLibrary/GenresService.cs+++ b/MediaBrowser.Api/UserLibrary/GenresService.cs@@ -62,7 +62,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetItem(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -96,7 +96,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetResult(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.csindex 16243ba6bb..101a379ea7 100644--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs@@ -268,7 +268,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetItems(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/UserLibrary/MusicGenresService.cs b/MediaBrowser.Api/UserLibrary/MusicGenresService.csindex 945ac5a670..3f960ccbe9 100644--- a/MediaBrowser.Api/UserLibrary/MusicGenresService.cs+++ b/MediaBrowser.Api/UserLibrary/MusicGenresService.cs@@ -57,7 +57,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetItem(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -91,7 +91,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetResult(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/UserLibrary/PersonsService.cs b/MediaBrowser.Api/UserLibrary/PersonsService.csindex 03e710ae81..32700d21ab 100644--- a/MediaBrowser.Api/UserLibrary/PersonsService.cs+++ b/MediaBrowser.Api/UserLibrary/PersonsService.cs@@ -74,7 +74,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetItem(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -108,7 +108,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetResult(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/UserLibrary/StudiosService.cs b/MediaBrowser.Api/UserLibrary/StudiosService.csindex 8b1eeec0f8..cf4e333e1b 100644--- a/MediaBrowser.Api/UserLibrary/StudiosService.cs+++ b/MediaBrowser.Api/UserLibrary/StudiosService.cs@@ -62,7 +62,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetItem(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -96,7 +96,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetResult(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.csindex d3995ae2b2..c2abc6ad11 100644--- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs+++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs@@ -1,4 +1,5 @@-using MediaBrowser.Controller.Dto;+using MediaBrowser.Common.Extensions;+using MediaBrowser.Controller.Dto;using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Entities.Movies;using MediaBrowser.Controller.Entities.TV;@@ -7,6 +8,7 @@ using MediaBrowser.Controller.Session;using MediaBrowser.Model.Dto;using MediaBrowser.Model.Entities;using MediaBrowser.Model.Querying;+using MediaBrowser.Model.Serialization;using ServiceStack;using System;using System.Collections.Generic;@@ -411,7 +413,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetAsync(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}private List<BaseItemDto> GetAsync(GetSpecialFeatures request)@@ -477,7 +479,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetAsync(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}private List<BaseItemDto> GetAsync(GetLocalTrailers request)@@ -521,7 +523,7 @@ namespace MediaBrowser.Api.UserLibraryvar result = _dtoService.GetBaseItemDto(item, fields, user);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -540,7 +542,7 @@ namespace MediaBrowser.Api.UserLibraryvar result = _dtoService.GetBaseItemDto(item, fields, user);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -570,7 +572,7 @@ namespace MediaBrowser.Api.UserLibraryTotalRecordCount = dtos.Length};- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/UserLibrary/YearsService.cs b/MediaBrowser.Api/UserLibrary/YearsService.csindex 3c54d5b369..7024d52563 100644--- a/MediaBrowser.Api/UserLibrary/YearsService.cs+++ b/MediaBrowser.Api/UserLibrary/YearsService.cs@@ -62,7 +62,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetItem(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -96,7 +96,7 @@ namespace MediaBrowser.Api.UserLibrary{var result = GetResult(request);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.csindex 254fa6ff1e..80260c83cb 100644--- a/MediaBrowser.Api/UserService.cs+++ b/MediaBrowser.Api/UserService.cs@@ -225,7 +225,7 @@ namespace MediaBrowser.Api.Select(_dtoService.GetUserDto).ToList();- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>@@ -244,7 +244,7 @@ namespace MediaBrowser.Apivar result = _dtoService.GetUserDto(user);- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}/// <summary>diff --git a/MediaBrowser.Api/VideosService.cs b/MediaBrowser.Api/VideosService.csindex d67c290229..fb58e58b7b 100644--- a/MediaBrowser.Api/VideosService.cs+++ b/MediaBrowser.Api/VideosService.cs@@ -69,7 +69,7 @@ namespace MediaBrowser.ApiTotalRecordCount = items.Length};- return ToOptimizedResult(result);+ return ToOptimizedSerializedResultUsingCache(result);}}}diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex 5a041860bb..650a9bad09 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -253,6 +253,15 @@ namespace MediaBrowser.Controller.Entities}}+ [IgnoreDataMember]+ public IEnumerable<string> PhysicalLocations+ {+ get+ {+ return ResolveArgs.PhysicalLocations;+ }+ }+/// <summary>/// Resets the resolve args./// </summary>diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.csindex 0d6bed90b9..6220bc4d51 100644--- a/MediaBrowser.Controller/Entities/CollectionFolder.cs+++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs@@ -84,7 +84,7 @@ namespace MediaBrowser.Controller.Entitiestry{- locationsDicionary = ResolveArgs.PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);+ locationsDicionary = PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);}catch (IOException ex){@@ -116,7 +116,7 @@ namespace MediaBrowser.Controller.Entitiestry{- locationsDicionary = ResolveArgs.PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);+ locationsDicionary = PhysicalLocations.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);}catch (IOException ex){diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.csindex 94db048647..02da2fe618 100644--- a/MediaBrowser.Controller/Entities/Folder.cs+++ b/MediaBrowser.Controller/Entities/Folder.cs@@ -1079,7 +1079,7 @@ namespace MediaBrowser.Controller.Entitiesif (i.LocationType != LocationType.Remote){- if (i.ResolveArgs.PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase))+ if (i.PhysicalLocations.Contains(path, StringComparer.OrdinalIgnoreCase)){return true;}diff --git a/MediaBrowser.Controller/Net/IHttpResultFactory.cs b/MediaBrowser.Controller/Net/IHttpResultFactory.csindex 0614db12e6..b7dff96cd9 100644--- a/MediaBrowser.Controller/Net/IHttpResultFactory.cs+++ b/MediaBrowser.Controller/Net/IHttpResultFactory.cs@@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Net/// <param name="factoryFn">The factory function that creates the response object.</param>/// <param name="responseHeaders">The response headers.</param>/// <returns>System.Object.</returns>- object GetOptimizedResultUsingCache<T>(IRequest requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, IDictionary<string, string> responseHeaders = null)+ object GetOptimizedResultUsingCache<T>(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, IDictionary<string, string> responseHeaders = null)where T : class;/// <summary>@@ -65,7 +65,7 @@ namespace MediaBrowser.Controller.Net/// <param name="contentType">Type of the content.</param>/// <param name="responseHeaders">The response headers.</param>/// <returns>System.Object.</returns>- object GetCachedResult<T>(IRequest requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, string contentType, IDictionary<string, string> responseHeaders = null)+ object GetCachedResult<T>(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, string contentType, IDictionary<string, string> responseHeaders = null)where T : class;/// <summary>@@ -94,5 +94,15 @@ namespace MediaBrowser.Controller.Net/// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param>/// <returns>System.Object.</returns>object GetStaticFileResult(IRequest requestContext, string path, FileShare fileShare = FileShare.Read, IDictionary<string, string> responseHeaders = null, bool isHeadRequest = false);++ /// <summary>+ /// Gets the optimized serialized result using cache.+ /// </summary>+ /// <typeparam name="T"></typeparam>+ /// <param name="request">The request.</param>+ /// <param name="result">The result.</param>+ /// <returns>System.Object.</returns>+ object GetOptimizedSerializedResultUsingCache<T>(IRequest request, T result)+ where T : class;}}diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.csindex 2d0fed02d1..e4701a1161 100644--- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs+++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs@@ -1,12 +1,10 @@using MediaBrowser.Common.IO;using MediaBrowser.Controller.Configuration;-using MediaBrowser.Controller.Entities.Audio;using MediaBrowser.Controller.Entities.Movies;using MediaBrowser.Controller.Entities.TV;using MediaBrowser.Controller.Library;using MediaBrowser.Controller.Localization;using MediaBrowser.Controller.Providers;-using MediaBrowser.Model.Configuration;using MediaBrowser.Model.Entities;using MediaBrowser.Model.Logging;using MediaBrowser.Providers.Manager;@@ -48,9 +46,9 @@ namespace MediaBrowser.Providers.BoxSetsreturn _libraryManager.UpdateItem(item, reason, cancellationToken);}- protected override ItemUpdateType AfterMetadataRefresh(BoxSet item)+ protected override ItemUpdateType BeforeSave(BoxSet item){- var updateType = base.AfterMetadataRefresh(item);+ var updateType = base.BeforeSave(item);if (!item.LockedFields.Contains(MetadataFields.OfficialRating)){diff --git a/MediaBrowser.Providers/CollectionFolderImageProvider.cs b/MediaBrowser.Providers/CollectionFolderImageProvider.csindex 12f13262d1..e4ea36dd12 100644--- a/MediaBrowser.Providers/CollectionFolderImageProvider.cs+++ b/MediaBrowser.Providers/CollectionFolderImageProvider.cs@@ -31,14 +31,14 @@ namespace MediaBrowser.Providersprotected override FileSystemInfo GetImage(BaseItem item, ItemResolveArgs args, string filenameWithoutExtension){- return item.ResolveArgs.PhysicalLocations+ return item.PhysicalLocations.Select(i => GetImageFromLocation(i, filenameWithoutExtension)).FirstOrDefault(i => i != null);}protected override Guid GetFileSystemStamp(IEnumerable<BaseItem> items){- var files = items.SelectMany(i => i.ResolveArgs.PhysicalLocations)+ var files = items.SelectMany(i => i.PhysicalLocations).Select(i => new DirectoryInfo(i)).SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly)).Where(i =>diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.csindex 349a4de97c..da82dcb3fb 100644--- a/MediaBrowser.Providers/Manager/MetadataService.cs+++ b/MediaBrowser.Providers/Manager/MetadataService.cs@@ -100,8 +100,6 @@ namespace MediaBrowser.Providers.ManagerrefreshResult.SetDateLastMetadataRefresh(DateTime.UtcNow);refreshResult.AddImageProvidersRefreshed(result.Providers);}-- updateType = updateType | AfterMetadataRefresh(itemOfType);}// Next run remote image providers, but only if local image providers didn't throw an exception@@ -120,6 +118,8 @@ namespace MediaBrowser.Providers.Manager}}+ updateType = updateType | BeforeSave(itemOfType);+var providersHadChanges = updateType > ItemUpdateType.Unspecified;if (refreshOptions.ForceSave || providersHadChanges)@@ -149,20 +149,21 @@ namespace MediaBrowser.Providers.Manager}/// <summary>- /// Afters the metadata refresh.+ /// Befores the metadata refresh./// </summary>/// <param name="item">The item.</param>- protected virtual ItemUpdateType AfterMetadataRefresh(TItemType item)+ /// <returns>ItemUpdateType.</returns>+ protected virtual ItemUpdateType BeforeMetadataRefresh(TItemType item){return ItemUpdateType.Unspecified;}/// <summary>- /// Befores the metadata refresh.+ /// Befores the save./// </summary>/// <param name="item">The item.</param>/// <returns>ItemUpdateType.</returns>- protected virtual ItemUpdateType BeforeMetadataRefresh(TItemType item)+ protected virtual ItemUpdateType BeforeSave(TItemType item){return ItemUpdateType.Unspecified;}diff --git a/MediaBrowser.Providers/Music/AlbumMetadataService.cs b/MediaBrowser.Providers/Music/AlbumMetadataService.csindex 8b9ebdc702..024e44cad2 100644--- a/MediaBrowser.Providers/Music/AlbumMetadataService.cs+++ b/MediaBrowser.Providers/Music/AlbumMetadataService.cs@@ -47,9 +47,9 @@ namespace MediaBrowser.Providers.Musicreturn _libraryManager.UpdateItem(item, reason, cancellationToken);}- protected override ItemUpdateType AfterMetadataRefresh(MusicAlbum item)+ protected override ItemUpdateType BeforeSave(MusicAlbum item){- var updateType = base.AfterMetadataRefresh(item);+ var updateType = base.BeforeSave(item);var songs = item.RecursiveChildren.OfType<Audio>().ToList();diff --git a/MediaBrowser.Providers/Music/ArtistMetadataService.cs b/MediaBrowser.Providers/Music/ArtistMetadataService.csindex e91679607d..1642cdfaab 100644--- a/MediaBrowser.Providers/Music/ArtistMetadataService.cs+++ b/MediaBrowser.Providers/Music/ArtistMetadataService.cs@@ -42,9 +42,9 @@ namespace MediaBrowser.Providers.Musicreturn _libraryManager.UpdateItem(item, reason, cancellationToken);}- protected override ItemUpdateType AfterMetadataRefresh(MusicArtist item)+ protected override ItemUpdateType BeforeSave(MusicArtist item){- var updateType = base.AfterMetadataRefresh(item);+ var updateType = base.BeforeSave(item);if (!item.IsAccessedByName && !item.LockedFields.Contains(MetadataFields.Genres)){diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.csindex ffd6d17b29..ccefd370cc 100644--- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs+++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs@@ -41,9 +41,9 @@ namespace MediaBrowser.Providers.TVreturn _libraryManager.UpdateItem(item, reason, cancellationToken);}- protected override ItemUpdateType AfterMetadataRefresh(Series item)+ protected override ItemUpdateType BeforeSave(Series item){- var updateType = base.AfterMetadataRefresh(item);+ var updateType = base.BeforeSave(item);var episodes = item.RecursiveChildren.OfType<Episode>()diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.csindex e4d86f550b..1c31b8ac64 100644--- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs+++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs@@ -142,24 +142,59 @@ namespace MediaBrowser.Providers.TVawait ExtractEpisodes(seriesDataPath, Path.Combine(seriesDataPath, preferredMetadataLanguage + ".xml"), lastTvDbUpdateTime).ConfigureAwait(false);}- internal async Task EnsureSeriesInfo(string seriesId, string preferredMetadataLanguage, CancellationToken cancellationToken)+ private readonly Task _cachedTask = Task.FromResult(true);+ internal Task EnsureSeriesInfo(string seriesId, string preferredMetadataLanguage, CancellationToken cancellationToken){var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesId);Directory.CreateDirectory(seriesDataPath);- var files = Directory.EnumerateFiles(seriesDataPath, "*.xml", SearchOption.TopDirectoryOnly)- .Select(Path.GetFileName)+ var files = new DirectoryInfo(seriesDataPath).EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly).ToList();var seriesXmlFilename = preferredMetadataLanguage + ".xml";+ var download = false;+ var automaticUpdatesEnabled = _config.Configuration.EnableTvDbUpdates;++ var seriesFile = files.FirstOrDefault(i => string.Equals(seriesXmlFilename, i.Name, StringComparison.OrdinalIgnoreCase));+ if (seriesFile == null || !seriesFile.Exists)+ {+ // No need to check age if automatic updates are enabled+ if (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(seriesFile)).TotalDays > 7)+ {+ download = true;+ }+ }++ var actorsXml = files.FirstOrDefault(i => string.Equals("actors.xml", i.Name, StringComparison.OrdinalIgnoreCase));+ if (actorsXml == null || !actorsXml.Exists)+ {+ // No need to check age if automatic updates are enabled+ if (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(actorsXml)).TotalDays > 7)+ {+ download = true;+ }+ }++ var bannersXml = files.FirstOrDefault(i => string.Equals("banners.xml", i.Name, StringComparison.OrdinalIgnoreCase));+ if (bannersXml == null || !bannersXml.Exists)+ {+ // No need to check age if automatic updates are enabled+ if (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(bannersXml)).TotalDays > 7)+ {+ download = true;+ }+ }+// Only download if not already there// The prescan task will take care of updates so we don't need to re-download here- if (!files.Contains("banners.xml", StringComparer.OrdinalIgnoreCase) || !files.Contains("actors.xml", StringComparer.OrdinalIgnoreCase) || !files.Contains(seriesXmlFilename, StringComparer.OrdinalIgnoreCase))+ if (download){- await DownloadSeriesZip(seriesId, seriesDataPath, null, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);+ return DownloadSeriesZip(seriesId, seriesDataPath, null, preferredMetadataLanguage, cancellationToken);}++ return _cachedTask;}/// <summary>diff --git a/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.csindex bbcc145246..32d4c7708c 100644--- a/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs+++ b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs@@ -279,7 +279,7 @@ namespace MediaBrowser.Server.Implementations.EntryPointstry{return i.LocationType == LocationType.FileSystem &&- i.ResolveArgs.PhysicalLocations.Contains(item.Path);+ i.PhysicalLocations.Contains(item.Path);}catch (Exception ex){diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.csindex 9359261c56..3712a58f5c 100644--- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs@@ -1,9 +1,10 @@using MediaBrowser.Common.Extensions;using MediaBrowser.Common.IO;-using MediaBrowser.Common.Net;-using MediaBrowser.Controller.IO;using MediaBrowser.Controller.Net;using MediaBrowser.Model.Logging;+using MediaBrowser.Model.Serialization;+using ServiceStack;+using ServiceStack.Web;using System;using System.Collections.Generic;using System.Globalization;@@ -11,8 +12,6 @@ using System.IO;using System.Net;using System.Text;using System.Threading.Tasks;-using ServiceStack;-using ServiceStack.Web;using MimeTypes = MediaBrowser.Common.Net.MimeTypes;namespace MediaBrowser.Server.Implementations.HttpServer@@ -27,14 +26,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer/// </summary>private readonly ILogger _logger;private readonly IFileSystem _fileSystem;+ private readonly IJsonSerializer _jsonSerializer;/// <summary>- /// Initializes a new instance of the <see cref="HttpResultFactory"/> class.+ /// Initializes a new instance of the <see cref="HttpResultFactory" /> class./// </summary>/// <param name="logManager">The log manager.</param>- public HttpResultFactory(ILogManager logManager, IFileSystem fileSystem)+ /// <param name="fileSystem">The file system.</param>+ /// <param name="jsonSerializer">The json serializer.</param>+ public HttpResultFactory(ILogManager logManager, IFileSystem fileSystem, IJsonSerializer jsonSerializer){_fileSystem = fileSystem;+ _jsonSerializer = jsonSerializer;_logger = logManager.GetLogger("HttpResultFactory");}@@ -151,12 +154,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer/// <param name="factoryFn">The factory fn.</param>/// <param name="responseHeaders">The response headers.</param>/// <returns>System.Object.</returns>- /// <exception cref="System.ArgumentNullException">- /// cacheKey+ /// <exception cref="System.ArgumentNullException">cacheKey/// or- /// factoryFn- /// </exception>- public object GetOptimizedResultUsingCache<T>(IRequest requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, IDictionary<string, string> responseHeaders = null)+ /// factoryFn</exception>+ public object GetOptimizedResultUsingCache<T>(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, IDictionary<string, string> responseHeaders = null)where T : class{if (cacheKey == Guid.Empty)@@ -199,7 +200,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer/// <param name="responseHeaders">The response headers.</param>/// <returns>System.Object.</returns>/// <exception cref="System.ArgumentNullException">cacheKey</exception>- public object GetCachedResult<T>(IRequest requestContext, Guid cacheKey, DateTime lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, string contentType, IDictionary<string, string> responseHeaders = null)+ public object GetCachedResult<T>(IRequest requestContext, Guid cacheKey, DateTime? lastDateModified, TimeSpan? cacheDuration, Func<T> factoryFn, string contentType, IDictionary<string, string> responseHeaders = null)where T : class{if (cacheKey == Guid.Empty)@@ -661,5 +662,14 @@ namespace MediaBrowser.Server.Implementations.HttpServerthrow error;}++ public object GetOptimizedSerializedResultUsingCache<T>(IRequest request, T result)+ where T : class+ {+ var json = _jsonSerializer.SerializeToString(result);+ var cacheKey = json.GetMD5();++ return GetOptimizedResultUsingCache(request, cacheKey, null, null, () => result);+ }}}\ No newline at end of filediff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.csindex 58141902ed..38f5cb62a8 100644--- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs+++ b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs@@ -166,8 +166,7 @@ namespace MediaBrowser.Server.Implementations.IO{try{- // Accessing ResolveArgs could involve file system access- return f.ResolveArgs.PhysicalLocations;+ return f.PhysicalLocations;}catch (IOException){diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.csindex 1e04f7e097..8294bfed62 100644--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs@@ -270,6 +270,7 @@ namespace MediaBrowser.Server.Implementations.Library/// </summary>private string _seasonZeroDisplayName;+ private bool _wizardCompleted;/// <summary>/// Records the configuration values./// </summary>@@ -278,6 +279,7 @@ namespace MediaBrowser.Server.Implementations.Library{_seasonZeroDisplayName = configuration.SeasonZeroDisplayName;_itemsByNamePath = ConfigurationManager.ApplicationPaths.ItemsByNamePath;+ _wizardCompleted = configuration.IsStartupWizardCompleted;}/// <summary>@@ -298,6 +300,7 @@ namespace MediaBrowser.Server.Implementations.Libraryvar newSeasonZeroName = ConfigurationManager.Configuration.SeasonZeroDisplayName;var seasonZeroNameChanged = !string.Equals(_seasonZeroDisplayName, newSeasonZeroName, StringComparison.CurrentCulture);+ var wizardChanged = config.IsStartupWizardCompleted != _wizardCompleted;RecordConfigurationValues(config);@@ -308,7 +311,7 @@ namespace MediaBrowser.Server.Implementations.Libraryawait UpdateSeasonZeroNames(newSeasonZeroName, CancellationToken.None).ConfigureAwait(false);}- if (seasonZeroNameChanged || ibnPathChanged)+ if (seasonZeroNameChanged || ibnPathChanged || wizardChanged){_taskManager.CancelIfRunningAndQueue<RefreshMediaLibraryTask>();}@@ -1479,7 +1482,7 @@ namespace MediaBrowser.Server.Implementations.Librarytry{- return i.ResolveArgs.PhysicalLocations.Contains(item.Path);+ return i.PhysicalLocations.Contains(item.Path);}catch (IOException ex){diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.csindex 88a928795a..323a636740 100644--- a/MediaBrowser.ServerApplication/ApplicationHost.cs+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs@@ -250,7 +250,7 @@ namespace MediaBrowser.ServerApplication{await base.RegisterResources(progress).ConfigureAwait(false);- RegisterSingleInstance<IHttpResultFactory>(new HttpResultFactory(LogManager, FileSystemManager));+ RegisterSingleInstance<IHttpResultFactory>(new HttpResultFactory(LogManager, FileSystemManager, JsonSerializer));RegisterSingleInstance<IServerApplicationHost>(this);RegisterSingleInstance<IServerApplicationPaths>(ApplicationPaths);