From 8ce3e74e8112a94773df22827849bf274fc88198 Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sun, 24 Feb 2013 16:53:54 -0500 Subject: More DI --- MediaBrowser.Controller/Drawing/ImageManager.cs | 45 ++- MediaBrowser.Controller/Entities/User.cs | 15 +- MediaBrowser.Controller/IServerApplicationPaths.cs | 85 ++++++ MediaBrowser.Controller/Kernel.cs | 64 ++-- .../MediaBrowser.Controller.csproj | 2 +- MediaBrowser.Controller/MediaInfo/FFMpegManager.cs | 79 +++-- .../MediaInfo/FFProbeVideoInfoProvider.cs | 30 +- .../Providers/Movies/MovieDbProvider.cs | 31 +- .../Providers/Movies/MovieProviderFromJson.cs | 8 +- .../Providers/Movies/PersonProviderFromJson.cs | 8 +- .../Providers/Movies/TmdbPersonProvider.cs | 29 +- .../ScheduledTasks/ChapterImagesTask.cs | 4 +- .../ScheduledTasks/ImageCleanupTask.cs | 7 +- .../ScheduledTasks/PeopleValidationTask.cs | 4 +- .../ScheduledTasks/PluginUpdateTask.cs | 4 +- .../ScheduledTasks/RefreshMediaLibraryTask.cs | 4 +- MediaBrowser.Controller/ServerApplicationPaths.cs | 334 --------------------- .../Updates/InstallationManager.cs | 46 +-- 18 files changed, 339 insertions(+), 460 deletions(-) create mode 100644 MediaBrowser.Controller/IServerApplicationPaths.cs delete mode 100644 MediaBrowser.Controller/ServerApplicationPaths.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Drawing/ImageManager.cs b/MediaBrowser.Controller/Drawing/ImageManager.cs index a0ba9d550..766d56115 100644 --- a/MediaBrowser.Controller/Drawing/ImageManager.cs +++ b/MediaBrowser.Controller/Drawing/ImageManager.cs @@ -1,12 +1,12 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; -using MediaBrowser.Common.Kernel; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Serialization; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Drawing /// /// Class ImageManager /// - public class ImageManager : BaseManager + public class ImageManager : IDisposable { /// /// Gets the image size cache. @@ -57,20 +57,32 @@ namespace MediaBrowser.Controller.Drawing /// private readonly ILogger _logger; + /// + /// The _protobuf serializer + /// + private readonly IProtobufSerializer _protobufSerializer; + + /// + /// The _kernel + /// + private readonly Kernel _kernel; + /// /// Initializes a new instance of the class. /// /// The kernel. + /// The protobuf serializer. /// The logger. - public ImageManager(Kernel kernel, ILogger logger) - : base(kernel) + public ImageManager(Kernel kernel, IProtobufSerializer protobufSerializer, ILogger logger) { + _protobufSerializer = protobufSerializer; _logger = logger; + _kernel = kernel; - ImageSizeCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "image-sizes")); - ResizedImageCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "resized-images")); - CroppedImageCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "cropped-images")); - EnhancedImageCache = new FileSystemRepository(Path.Combine(Kernel.ApplicationPaths.ImageCachePath, "enhanced-images")); + ImageSizeCache = new FileSystemRepository(Path.Combine(_kernel.ApplicationPaths.ImageCachePath, "image-sizes")); + ResizedImageCache = new FileSystemRepository(Path.Combine(_kernel.ApplicationPaths.ImageCachePath, "resized-images")); + CroppedImageCache = new FileSystemRepository(Path.Combine(_kernel.ApplicationPaths.ImageCachePath, "cropped-images")); + EnhancedImageCache = new FileSystemRepository(Path.Combine(_kernel.ApplicationPaths.ImageCachePath, "enhanced-images")); } /// @@ -276,7 +288,7 @@ namespace MediaBrowser.Controller.Drawing try { - var result = Kernel.ProtobufSerializer.DeserializeFromFile(fullCachePath); + var result = _protobufSerializer.DeserializeFromFile(fullCachePath); return new ImageSize { Width = result[0], Height = result[1] }; } @@ -305,7 +317,7 @@ namespace MediaBrowser.Controller.Drawing { var output = new[] { width, height }; - Kernel.ProtobufSerializer.SerializeToFile(output, cachePath); + _protobufSerializer.SerializeToFile(output, cachePath); } /// @@ -472,7 +484,7 @@ namespace MediaBrowser.Controller.Drawing throw new ArgumentNullException("item"); } - var supportedEnhancers = Kernel.ImageEnhancers.Where(i => i.Supports(item, imageType)).ToList(); + var supportedEnhancers = _kernel.ImageEnhancers.Where(i => i.Supports(item, imageType)).ToList(); // No enhancement - don't cache if (supportedEnhancers.Count == 0) @@ -526,7 +538,7 @@ namespace MediaBrowser.Controller.Drawing var dateModified = GetImageDateModified(item, imagePath); - var supportedEnhancers = Kernel.ImageEnhancers.Where(i => i.Supports(item, imageType)); + var supportedEnhancers = _kernel.ImageEnhancers.Where(i => i.Supports(item, imageType)); return GetImageCacheTag(imagePath, dateModified, supportedEnhancers, item, imageType); } @@ -600,11 +612,16 @@ namespace MediaBrowser.Controller.Drawing return result; } + public void Dispose() + { + Dispose(true); + } + /// /// Releases unmanaged and - optionally - managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - protected override void Dispose(bool dispose) + protected void Dispose(bool dispose) { if (dispose) { @@ -613,8 +630,6 @@ namespace MediaBrowser.Controller.Drawing CroppedImageCache.Dispose(); EnhancedImageCache.Dispose(); } - - base.Dispose(dispose); } } } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 426e7f18e..5abd3e5a8 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -1,15 +1,13 @@ using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.IO; -using MediaBrowser.Common.Serialization; using MediaBrowser.Controller.IO; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Tasks; using System; using System.IO; using System.Linq; using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Entities { @@ -170,7 +168,7 @@ namespace MediaBrowser.Controller.Entities get { // Lazy load - LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => XmlSerializer.GetXmlConfiguration(ConfigurationFilePath, Logger)); + LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => (UserConfiguration)Kernel.Instance.GetXmlConfiguration(typeof(UserConfiguration), ConfigurationFilePath)); return _configuration; } private set @@ -338,9 +336,9 @@ namespace MediaBrowser.Controller.Entities /// /// Saves the current configuration to the file system /// - public void SaveConfiguration() + public void SaveConfiguration(IXmlSerializer serializer) { - XmlSerializer.SerializeToFile(Configuration, ConfigurationFilePath); + serializer.SerializeToFile(Configuration, ConfigurationFilePath); } /// @@ -376,8 +374,9 @@ namespace MediaBrowser.Controller.Entities /// Updates the configuration. /// /// The config. + /// The serializer. /// config - public void UpdateConfiguration(UserConfiguration config) + public void UpdateConfiguration(UserConfiguration config, IXmlSerializer serializer) { if (config == null) { @@ -387,7 +386,7 @@ namespace MediaBrowser.Controller.Entities var customLibraryChanged = config.UseCustomLibrary != Configuration.UseCustomLibrary; Configuration = config; - SaveConfiguration(); + SaveConfiguration(serializer); // Force these to be lazy loaded again if (customLibraryChanged) diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.cs new file mode 100644 index 000000000..b5fcdef28 --- /dev/null +++ b/MediaBrowser.Controller/IServerApplicationPaths.cs @@ -0,0 +1,85 @@ +using MediaBrowser.Common.Kernel; + +namespace MediaBrowser.Controller +{ + public interface IServerApplicationPaths : IApplicationPaths + { + /// + /// Gets the path to the base root media directory + /// + /// The root folder path. + string RootFolderPath { get; } + + /// + /// Gets the path to the default user view directory. Used if no specific user view is defined. + /// + /// The default user views path. + string DefaultUserViewsPath { get; } + + /// + /// Gets the path to localization data. + /// + /// The localization path. + string LocalizationPath { get; } + + /// + /// Gets the path to the Images By Name directory + /// + /// The images by name path. + string ImagesByNamePath { get; } + + /// + /// Gets the path to the People directory + /// + /// The people path. + string PeoplePath { get; } + + /// + /// Gets the path to the Genre directory + /// + /// The genre path. + string GenrePath { get; } + + /// + /// Gets the path to the Studio directory + /// + /// The studio path. + string StudioPath { get; } + + /// + /// Gets the path to the Year directory + /// + /// The year path. + string YearPath { get; } + + /// + /// Gets the path to the General IBN directory + /// + /// The general path. + string GeneralPath { get; } + + /// + /// Gets the path to the Ratings IBN directory + /// + /// The ratings path. + string RatingsPath { get; } + + /// + /// Gets the path to the user configuration directory + /// + /// The user configuration directory path. + string UserConfigurationDirectoryPath { get; } + + /// + /// Gets the FF MPEG stream cache path. + /// + /// The FF MPEG stream cache path. + string FFMpegStreamCachePath { get; } + + /// + /// Gets the folder path to tools + /// + /// The media tools path. + string MediaToolsPath { get; } + } +} \ No newline at end of file diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index 5ee590bde..d879b888b 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -1,5 +1,6 @@ using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Plugins; +using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.IO; @@ -16,6 +17,7 @@ using MediaBrowser.Controller.Updates; using MediaBrowser.Controller.Weather; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Serialization; using MediaBrowser.Model.System; using System; using System.Collections.Generic; @@ -28,7 +30,7 @@ namespace MediaBrowser.Controller /// /// Class Kernel /// - public class Kernel : BaseKernel + public class Kernel : BaseKernel { /// /// The MB admin URL @@ -291,17 +293,24 @@ namespace MediaBrowser.Controller get { return 7359; } } + private readonly ITaskManager _taskManager; + /// /// Creates a kernel based on a Data path, which is akin to our current programdata path /// /// The app host. + /// The app paths. + /// The XML serializer. + /// The task manager. /// The logger. /// isoManager - public Kernel(IApplicationHost appHost, ILogger logger) - : base(appHost, logger) + public Kernel(IApplicationHost appHost, IServerApplicationPaths appPaths, IXmlSerializer xmlSerializer, ITaskManager taskManager, ILogger logger) + : base(appHost, appPaths, xmlSerializer, logger) { Instance = this; + _taskManager = taskManager; + // For now there's no real way to inject this properly BaseItem.Logger = logger; Ratings.Logger = logger; @@ -310,21 +319,10 @@ namespace MediaBrowser.Controller BaseMetadataProvider.Logger = logger; } - /// - /// Composes the exported values. - /// - protected override void RegisterExportedValues() - { - ApplicationHost.RegisterSingleInstance(this); - - base.RegisterExportedValues(); - } - /// /// Composes the parts with ioc container. /// - /// All types. - protected override void FindParts(Type[] allTypes) + protected override void FindParts() { InstallationManager = (InstallationManager)ApplicationHost.CreateInstance(typeof(InstallationManager)); FFMpegManager = (FFMpegManager)ApplicationHost.CreateInstance(typeof(FFMpegManager)); @@ -335,21 +333,21 @@ namespace MediaBrowser.Controller UserDataManager = (UserDataManager)ApplicationHost.CreateInstance(typeof(UserDataManager)); PluginSecurityManager = (PluginSecurityManager)ApplicationHost.CreateInstance(typeof(PluginSecurityManager)); - base.FindParts(allTypes); - - EntityResolutionIgnoreRules = GetExports(allTypes); - UserDataRepositories = GetExports(allTypes); - UserRepositories = GetExports(allTypes); - DisplayPreferencesRepositories = GetExports(allTypes); - ItemRepositories = GetExports(allTypes); - WeatherProviders = GetExports(allTypes); - IntroProviders = GetExports(allTypes); - PluginConfigurationPages = GetExports(allTypes); - ImageEnhancers = GetExports(allTypes).OrderBy(e => e.Priority).ToArray(); - PluginFolderCreators = GetExports(allTypes); - StringFiles = GetExports(allTypes); - EntityResolvers = GetExports(allTypes).OrderBy(e => e.Priority).ToArray(); - MetadataProviders = GetExports(allTypes).OrderBy(e => e.Priority).ToArray(); + base.FindParts(); + + EntityResolutionIgnoreRules = ApplicationHost.GetExports(); + UserDataRepositories = ApplicationHost.GetExports(); + UserRepositories = ApplicationHost.GetExports(); + DisplayPreferencesRepositories = ApplicationHost.GetExports(); + ItemRepositories = ApplicationHost.GetExports(); + WeatherProviders = ApplicationHost.GetExports(); + IntroProviders = ApplicationHost.GetExports(); + PluginConfigurationPages = ApplicationHost.GetExports(); + ImageEnhancers = ApplicationHost.GetExports().OrderBy(e => e.Priority).ToArray(); + PluginFolderCreators = ApplicationHost.GetExports(); + StringFiles = ApplicationHost.GetExports(); + EntityResolvers = ApplicationHost.GetExports().OrderBy(e => e.Priority).ToArray(); + MetadataProviders = ApplicationHost.GetExports().OrderBy(e => e.Priority).ToArray(); } /// @@ -471,7 +469,7 @@ namespace MediaBrowser.Controller { DisposeFileSystemManager(); - FileSystemManager = new FileSystemManager(this, Logger, TaskManager); + FileSystemManager = new FileSystemManager(this, Logger, _taskManager); FileSystemManager.StartWatchers(); } @@ -570,11 +568,11 @@ namespace MediaBrowser.Controller ProviderManager.ValidateCurrentlyRunningProviders(); // Any number of configuration settings could change the way the library is refreshed, so do that now - TaskManager.CancelIfRunningAndQueue(); + _taskManager.CancelIfRunningAndQueue(); if (refreshPeopleAfterUpdate) { - TaskManager.CancelIfRunningAndQueue(); + _taskManager.CancelIfRunningAndQueue(); } }); } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 35540020e..1e901055e 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -110,6 +110,7 @@ + @@ -183,7 +184,6 @@ - diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs index 9c9b0e9f2..0f535208b 100644 --- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs +++ b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs @@ -1,12 +1,10 @@ -using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.IO; -using MediaBrowser.Common.Kernel; -using MediaBrowser.Common.Serialization; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Serialization; using System; using System.Collections.Generic; using System.ComponentModel; @@ -23,7 +21,7 @@ namespace MediaBrowser.Controller.MediaInfo /// /// Class FFMpegManager /// - public class FFMpegManager : BaseManager + public class FFMpegManager : IDisposable { /// /// Gets or sets the video image cache. @@ -47,30 +45,66 @@ namespace MediaBrowser.Controller.MediaInfo /// Gets or sets the zip client. /// /// The zip client. - private IZipClient ZipClient { get; set; } + private readonly IZipClient _zipClient; + /// + /// The _logger + /// + private readonly Kernel _kernel; + /// /// The _logger /// private readonly ILogger _logger; + /// + /// Gets the json serializer. + /// + /// The json serializer. + private readonly IJsonSerializer _jsonSerializer; + + /// + /// The _protobuf serializer + /// + private readonly IProtobufSerializer _protobufSerializer; + /// /// Initializes a new instance of the class. /// /// The kernel. /// The zip client. + /// The json serializer. + /// The protobuf serializer. /// The logger. /// zipClient - public FFMpegManager(Kernel kernel, IZipClient zipClient, ILogger logger) - : base(kernel) + public FFMpegManager(Kernel kernel, IZipClient zipClient, IJsonSerializer jsonSerializer, IProtobufSerializer protobufSerializer, ILogger logger) { + if (kernel == null) + { + throw new ArgumentNullException("kernel"); + } if (zipClient == null) { throw new ArgumentNullException("zipClient"); } + if (jsonSerializer == null) + { + throw new ArgumentNullException("jsonSerializer"); + } + if (protobufSerializer == null) + { + throw new ArgumentNullException("protobufSerializer"); + } + if (logger == null) + { + throw new ArgumentNullException("logger"); + } + _kernel = kernel; + _zipClient = zipClient; + _jsonSerializer = jsonSerializer; + _protobufSerializer = protobufSerializer; _logger = logger; - ZipClient = zipClient; // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX); @@ -82,11 +116,16 @@ namespace MediaBrowser.Controller.MediaInfo Task.Run(() => VersionedDirectoryPath = GetVersionedDirectoryPath()); } + public void Dispose() + { + Dispose(true); + } + /// /// Releases unmanaged and - optionally - managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - protected override void Dispose(bool dispose) + protected void Dispose(bool dispose) { if (dispose) { @@ -95,8 +134,6 @@ namespace MediaBrowser.Controller.MediaInfo AudioImageCache.Dispose(); VideoImageCache.Dispose(); } - - base.Dispose(dispose); } /// @@ -186,7 +223,7 @@ namespace MediaBrowser.Controller.MediaInfo { if (_videoImagesDataPath == null) { - _videoImagesDataPath = Path.Combine(Kernel.ApplicationPaths.DataPath, "ffmpeg-video-images"); + _videoImagesDataPath = Path.Combine(_kernel.ApplicationPaths.DataPath, "ffmpeg-video-images"); if (!Directory.Exists(_videoImagesDataPath)) { @@ -212,7 +249,7 @@ namespace MediaBrowser.Controller.MediaInfo { if (_audioImagesDataPath == null) { - _audioImagesDataPath = Path.Combine(Kernel.ApplicationPaths.DataPath, "ffmpeg-audio-images"); + _audioImagesDataPath = Path.Combine(_kernel.ApplicationPaths.DataPath, "ffmpeg-audio-images"); if (!Directory.Exists(_audioImagesDataPath)) { @@ -238,7 +275,7 @@ namespace MediaBrowser.Controller.MediaInfo { if (_subtitleCachePath == null) { - _subtitleCachePath = Path.Combine(Kernel.ApplicationPaths.CachePath, "ffmpeg-subtitles"); + _subtitleCachePath = Path.Combine(_kernel.ApplicationPaths.CachePath, "ffmpeg-subtitles"); if (!Directory.Exists(_subtitleCachePath)) { @@ -265,7 +302,7 @@ namespace MediaBrowser.Controller.MediaInfo var filename = resource.Substring(resource.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) + prefix.Length); - var versionedDirectoryPath = Path.Combine(Kernel.ApplicationPaths.MediaToolsPath, Path.GetFileNameWithoutExtension(filename)); + var versionedDirectoryPath = Path.Combine(_kernel.ApplicationPaths.MediaToolsPath, Path.GetFileNameWithoutExtension(filename)); if (!Directory.Exists(versionedDirectoryPath)) { @@ -287,7 +324,7 @@ namespace MediaBrowser.Controller.MediaInfo { using (var resourceStream = assembly.GetManifestResourceStream(zipFileResourcePath)) { - ZipClient.ExtractAll(resourceStream, targetPath, false); + _zipClient.ExtractAll(resourceStream, targetPath, false); } } @@ -353,7 +390,7 @@ namespace MediaBrowser.Controller.MediaInfo // Avoid File.Exists by just trying to deserialize try { - return Task.FromResult(Kernel.ProtobufSerializer.DeserializeFromFile(cacheFilePath)); + return Task.FromResult(_protobufSerializer.DeserializeFromFile(cacheFilePath)); } catch (FileNotFoundException) { @@ -428,7 +465,7 @@ namespace MediaBrowser.Controller.MediaInfo process.BeginErrorReadLine(); } - result = JsonSerializer.DeserializeFromStream(process.StandardOutput.BaseStream); + result = _jsonSerializer.DeserializeFromStream(process.StandardOutput.BaseStream); if (extractChapters) { @@ -470,7 +507,7 @@ namespace MediaBrowser.Controller.MediaInfo AddChapters(result, standardError); } - Kernel.ProtobufSerializer.SerializeToFile(result, cacheFile); + _protobufSerializer.SerializeToFile(result, cacheFile); return result; } @@ -595,7 +632,7 @@ namespace MediaBrowser.Controller.MediaInfo if (saveItem && changesMade) { - await Kernel.ItemRepository.SaveItem(video, CancellationToken.None).ConfigureAwait(false); + await _kernel.ItemRepository.SaveItem(video, CancellationToken.None).ConfigureAwait(false); } } diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs index 443d28b67..8905656ef 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs @@ -4,6 +4,7 @@ using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.MediaInfo; using MediaBrowser.Model.Entities; using MediaBrowser.Model.MediaInfo; +using MediaBrowser.Model.Serialization; using System; using System.Collections.Generic; using System.IO; @@ -28,29 +29,44 @@ namespace MediaBrowser.Controller.Providers.MediaInfo /// Gets or sets the bluray examiner. /// /// The bluray examiner. - private IBlurayExaminer BlurayExaminer { get; set; } + private readonly IBlurayExaminer _blurayExaminer; - /// + /// /// The _iso manager /// private readonly IIsoManager _isoManager; + /// + /// The _protobuf serializer + /// + private readonly IProtobufSerializer _protobufSerializer; + /// /// Initializes a new instance of the class. /// /// The iso manager. /// The bluray examiner. + /// The protobuf serializer. /// blurayExaminer - public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer) + public FFProbeVideoInfoProvider(IIsoManager isoManager, IBlurayExaminer blurayExaminer, IProtobufSerializer protobufSerializer) : base() { + if (isoManager == null) + { + throw new ArgumentNullException("isoManager"); + } if (blurayExaminer == null) { throw new ArgumentNullException("blurayExaminer"); } + if (protobufSerializer == null) + { + throw new ArgumentNullException("protobufSerializer"); + } - BlurayExaminer = blurayExaminer; + _blurayExaminer = blurayExaminer; _isoManager = isoManager; + _protobufSerializer = protobufSerializer; BdInfoCache = new FileSystemRepository(Path.Combine(Kernel.Instance.ApplicationPaths.CachePath, "bdinfo")); } @@ -315,13 +331,13 @@ namespace MediaBrowser.Controller.Providers.MediaInfo try { - result = Kernel.Instance.ProtobufSerializer.DeserializeFromFile(cacheFile); + result = _protobufSerializer.DeserializeFromFile(cacheFile); } catch (FileNotFoundException) { result = GetBDInfo(inputPath); - Kernel.Instance.ProtobufSerializer.SerializeToFile(result, cacheFile); + _protobufSerializer.SerializeToFile(result, cacheFile); } cancellationToken.ThrowIfCancellationRequested(); @@ -400,7 +416,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo /// VideoStream. private BlurayDiscInfo GetBDInfo(string path) { - return BlurayExaminer.GetDiscInfo(path); + return _blurayExaminer.GetDiscInfo(path); } /// diff --git a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs index 72f8a3fc7..bc261de6d 100644 --- a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.Serialization; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Model.Entities; @@ -15,6 +14,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Providers.Movies { @@ -30,6 +30,27 @@ namespace MediaBrowser.Controller.Providers.Movies /// public class MovieDbProvider : BaseMetadataProvider { + /// + /// Gets the json serializer. + /// + /// The json serializer. + protected IJsonSerializer JsonSerializer { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// The json serializer. + /// jsonSerializer + public MovieDbProvider(IJsonSerializer jsonSerializer) + : base() + { + if (jsonSerializer == null) + { + throw new ArgumentNullException("jsonSerializer"); + } + JsonSerializer = jsonSerializer; + } + /// /// Gets the priority. /// @@ -93,7 +114,7 @@ namespace MediaBrowser.Controller.Providers.Movies { get { - LazyInitializer.EnsureInitialized(ref _tmdbSettingsTask, ref _tmdbSettingsTaskInitialized, ref _tmdbSettingsTaskSyncLock, GetTmdbSettings); + LazyInitializer.EnsureInitialized(ref _tmdbSettingsTask, ref _tmdbSettingsTaskInitialized, ref _tmdbSettingsTaskSyncLock, () => GetTmdbSettings(JsonSerializer)); return _tmdbSettingsTask; } } @@ -102,13 +123,13 @@ namespace MediaBrowser.Controller.Providers.Movies /// Gets the TMDB settings. /// /// Task{TmdbSettingsResult}. - private static async Task GetTmdbSettings() + private static async Task GetTmdbSettings(IJsonSerializer jsonSerializer) { try { using (var json = await Kernel.Instance.HttpManager.Get(String.Format(TmdbConfigUrl, ApiKey), Kernel.Instance.ResourcePools.MovieDb, CancellationToken.None).ConfigureAwait(false)) { - return JsonSerializer.DeserializeFromStream(json); + return jsonSerializer.DeserializeFromStream(json); } } catch (HttpException e) @@ -168,7 +189,7 @@ namespace MediaBrowser.Controller.Providers.Movies { //in addition to ours, we need to set the last refreshed time for the local data provider //so it won't see the new files we download and process them all over again - if (JsonProvider == null) JsonProvider = new MovieProviderFromJson(); + if (JsonProvider == null) JsonProvider = new MovieProviderFromJson(JsonSerializer); var data = item.ProviderData.GetValueOrDefault(JsonProvider.Id, new BaseProviderInfo { ProviderId = JsonProvider.Id }); data.LastRefreshed = value; item.ProviderData[JsonProvider.Id] = data; diff --git a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs index 45079ddda..5de17aab0 100644 --- a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs +++ b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs @@ -1,5 +1,5 @@ -using MediaBrowser.Common.Serialization; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Serialization; using System; using System.IO; using System.Threading; @@ -12,6 +12,10 @@ namespace MediaBrowser.Controller.Providers.Movies /// public class MovieProviderFromJson : MovieDbProvider { + public MovieProviderFromJson(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } + /// /// Gets the priority. /// diff --git a/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs b/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs index b4b4933e2..7517ec65c 100644 --- a/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs +++ b/MediaBrowser.Controller/Providers/Movies/PersonProviderFromJson.cs @@ -1,5 +1,5 @@ -using MediaBrowser.Common.Serialization; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Serialization; using System; using System.IO; using System.Threading; @@ -12,6 +12,10 @@ namespace MediaBrowser.Controller.Providers.Movies /// class PersonProviderFromJson : TmdbPersonProvider { + public PersonProviderFromJson(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } + /// /// Supportses the specified item. /// diff --git a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs index 7b5d62fb0..32013614c 100644 --- a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Serialization; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Net; using System; @@ -10,6 +9,7 @@ using System.Linq; using System.Net; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Providers.Movies { @@ -23,6 +23,27 @@ namespace MediaBrowser.Controller.Providers.Movies /// protected const string MetaFileName = "MBPerson.json"; + /// + /// Gets the json serializer. + /// + /// The json serializer. + protected IJsonSerializer JsonSerializer { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + /// The json serializer. + /// jsonSerializer + public TmdbPersonProvider(IJsonSerializer jsonSerializer) + : base() + { + if (jsonSerializer == null) + { + throw new ArgumentNullException("jsonSerializer"); + } + JsonSerializer = jsonSerializer; + } + /// /// Supportses the specified item. /// @@ -56,7 +77,7 @@ namespace MediaBrowser.Controller.Providers.Movies protected override async Task FetchAsyncInternal(BaseItem item, bool force, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); - + var person = (Person)item; var tasks = new List(); @@ -169,7 +190,7 @@ namespace MediaBrowser.Controller.Providers.Movies } cancellationToken.ThrowIfCancellationRequested(); - + if (searchResult != null && searchResult.Biography != null) { ProcessInfo(person, searchResult); diff --git a/MediaBrowser.Controller/ScheduledTasks/ChapterImagesTask.cs b/MediaBrowser.Controller/ScheduledTasks/ChapterImagesTask.cs index 1a64bb853..536033719 100644 --- a/MediaBrowser.Controller/ScheduledTasks/ChapterImagesTask.cs +++ b/MediaBrowser.Controller/ScheduledTasks/ChapterImagesTask.cs @@ -28,9 +28,9 @@ namespace MediaBrowser.Controller.ScheduledTasks /// Creates the triggers that define when the task will run /// /// IEnumerable{BaseTaskTrigger}. - protected override IEnumerable GetDefaultTriggers() + public override IEnumerable GetDefaultTriggers() { - return new BaseTaskTrigger[] + return new ITaskTrigger[] { new DailyTrigger { TimeOfDay = TimeSpan.FromHours(4) } }; diff --git a/MediaBrowser.Controller/ScheduledTasks/ImageCleanupTask.cs b/MediaBrowser.Controller/ScheduledTasks/ImageCleanupTask.cs index 8dd0895c9..7e0094a67 100644 --- a/MediaBrowser.Controller/ScheduledTasks/ImageCleanupTask.cs +++ b/MediaBrowser.Controller/ScheduledTasks/ImageCleanupTask.cs @@ -20,7 +20,8 @@ namespace MediaBrowser.Controller.ScheduledTasks /// Initializes a new instance of the class. /// /// The kernel. - /// + /// The task manager. + /// The logger. public ImageCleanupTask(Kernel kernel, ITaskManager taskManager, ILogger logger) : base(kernel, taskManager, logger) { @@ -30,9 +31,9 @@ namespace MediaBrowser.Controller.ScheduledTasks /// Creates the triggers that define when the task will run /// /// IEnumerable{BaseTaskTrigger}. - protected override IEnumerable GetDefaultTriggers() + public override IEnumerable GetDefaultTriggers() { - return new BaseTaskTrigger[] + return new ITaskTrigger[] { new DailyTrigger { TimeOfDay = TimeSpan.FromHours(2) } }; diff --git a/MediaBrowser.Controller/ScheduledTasks/PeopleValidationTask.cs b/MediaBrowser.Controller/ScheduledTasks/PeopleValidationTask.cs index ee55ff2e9..595de684d 100644 --- a/MediaBrowser.Controller/ScheduledTasks/PeopleValidationTask.cs +++ b/MediaBrowser.Controller/ScheduledTasks/PeopleValidationTask.cs @@ -26,9 +26,9 @@ namespace MediaBrowser.Controller.ScheduledTasks /// Creates the triggers that define when the task will run /// /// IEnumerable{BaseTaskTrigger}. - protected override IEnumerable GetDefaultTriggers() + public override IEnumerable GetDefaultTriggers() { - return new BaseTaskTrigger[] + return new ITaskTrigger[] { new DailyTrigger { TimeOfDay = TimeSpan.FromHours(2) }, diff --git a/MediaBrowser.Controller/ScheduledTasks/PluginUpdateTask.cs b/MediaBrowser.Controller/ScheduledTasks/PluginUpdateTask.cs index 854c3b82f..7a1007f1b 100644 --- a/MediaBrowser.Controller/ScheduledTasks/PluginUpdateTask.cs +++ b/MediaBrowser.Controller/ScheduledTasks/PluginUpdateTask.cs @@ -29,9 +29,9 @@ namespace MediaBrowser.Controller.ScheduledTasks /// Creates the triggers that define when the task will run /// /// IEnumerable{BaseTaskTrigger}. - protected override IEnumerable GetDefaultTriggers() + public override IEnumerable GetDefaultTriggers() { - return new BaseTaskTrigger[] { + return new ITaskTrigger[] { // 1:30am new DailyTrigger { TimeOfDay = TimeSpan.FromHours(1.5) }, diff --git a/MediaBrowser.Controller/ScheduledTasks/RefreshMediaLibraryTask.cs b/MediaBrowser.Controller/ScheduledTasks/RefreshMediaLibraryTask.cs index 76e60f2ef..104b432f4 100644 --- a/MediaBrowser.Controller/ScheduledTasks/RefreshMediaLibraryTask.cs +++ b/MediaBrowser.Controller/ScheduledTasks/RefreshMediaLibraryTask.cs @@ -27,9 +27,9 @@ namespace MediaBrowser.Controller.ScheduledTasks /// Gets the default triggers. /// /// IEnumerable{BaseTaskTrigger}. - protected override IEnumerable GetDefaultTriggers() + public override IEnumerable GetDefaultTriggers() { - return new BaseTaskTrigger[] { + return new ITaskTrigger[] { new StartupTrigger(), diff --git a/MediaBrowser.Controller/ServerApplicationPaths.cs b/MediaBrowser.Controller/ServerApplicationPaths.cs deleted file mode 100644 index a376afed8..000000000 --- a/MediaBrowser.Controller/ServerApplicationPaths.cs +++ /dev/null @@ -1,334 +0,0 @@ -using MediaBrowser.Common.Kernel; -using System.IO; - -namespace MediaBrowser.Controller -{ - /// - /// Extends BaseApplicationPaths to add paths that are only applicable on the server - /// - public class ServerApplicationPaths : BaseApplicationPaths - { - /// - /// The _root folder path - /// - private string _rootFolderPath; - /// - /// Gets the path to the base root media directory - /// - /// The root folder path. - public string RootFolderPath - { - get - { - if (_rootFolderPath == null) - { - _rootFolderPath = Path.Combine(ProgramDataPath, "Root"); - if (!Directory.Exists(_rootFolderPath)) - { - Directory.CreateDirectory(_rootFolderPath); - } - } - return _rootFolderPath; - } - } - - /// - /// The _default user views path - /// - private string _defaultUserViewsPath; - /// - /// Gets the path to the default user view directory. Used if no specific user view is defined. - /// - /// The default user views path. - public string DefaultUserViewsPath - { - get - { - if (_defaultUserViewsPath == null) - { - _defaultUserViewsPath = Path.Combine(RootFolderPath, "Default"); - if (!Directory.Exists(_defaultUserViewsPath)) - { - Directory.CreateDirectory(_defaultUserViewsPath); - } - } - return _defaultUserViewsPath; - } - } - - /// - /// The _localization path - /// - private string _localizationPath; - /// - /// Gets the path to localization data. - /// - /// The localization path. - public string LocalizationPath - { - get - { - if (_localizationPath == null) - { - _localizationPath = Path.Combine(ProgramDataPath, "Localization"); - if (!Directory.Exists(_localizationPath)) - { - Directory.CreateDirectory(_localizationPath); - } - } - return _localizationPath; - } - } - - /// - /// The _ibn path - /// - private string _ibnPath; - /// - /// Gets the path to the Images By Name directory - /// - /// The images by name path. - public string ImagesByNamePath - { - get - { - if (_ibnPath == null) - { - _ibnPath = Path.Combine(ProgramDataPath, "ImagesByName"); - if (!Directory.Exists(_ibnPath)) - { - Directory.CreateDirectory(_ibnPath); - } - } - - return _ibnPath; - } - } - - /// - /// The _people path - /// - private string _peoplePath; - /// - /// Gets the path to the People directory - /// - /// The people path. - public string PeoplePath - { - get - { - if (_peoplePath == null) - { - _peoplePath = Path.Combine(ImagesByNamePath, "People"); - if (!Directory.Exists(_peoplePath)) - { - Directory.CreateDirectory(_peoplePath); - } - } - - return _peoplePath; - } - } - - /// - /// The _genre path - /// - private string _genrePath; - /// - /// Gets the path to the Genre directory - /// - /// The genre path. - public string GenrePath - { - get - { - if (_genrePath == null) - { - _genrePath = Path.Combine(ImagesByNamePath, "Genre"); - if (!Directory.Exists(_genrePath)) - { - Directory.CreateDirectory(_genrePath); - } - } - - return _genrePath; - } - } - - /// - /// The _studio path - /// - private string _studioPath; - /// - /// Gets the path to the Studio directory - /// - /// The studio path. - public string StudioPath - { - get - { - if (_studioPath == null) - { - _studioPath = Path.Combine(ImagesByNamePath, "Studio"); - if (!Directory.Exists(_studioPath)) - { - Directory.CreateDirectory(_studioPath); - } - } - - return _studioPath; - } - } - - /// - /// The _year path - /// - private string _yearPath; - /// - /// Gets the path to the Year directory - /// - /// The year path. - public string YearPath - { - get - { - if (_yearPath == null) - { - _yearPath = Path.Combine(ImagesByNamePath, "Year"); - if (!Directory.Exists(_yearPath)) - { - Directory.CreateDirectory(_yearPath); - } - } - - return _yearPath; - } - } - - /// - /// The _general path - /// - private string _generalPath; - /// - /// Gets the path to the General IBN directory - /// - /// The general path. - public string GeneralPath - { - get - { - if (_generalPath == null) - { - _generalPath = Path.Combine(ImagesByNamePath, "General"); - if (!Directory.Exists(_generalPath)) - { - Directory.CreateDirectory(_generalPath); - } - } - - return _generalPath; - } - } - - /// - /// The _ratings path - /// - private string _ratingsPath; - /// - /// Gets the path to the Ratings IBN directory - /// - /// The ratings path. - public string RatingsPath - { - get - { - if (_ratingsPath == null) - { - _ratingsPath = Path.Combine(ImagesByNamePath, "Ratings"); - if (!Directory.Exists(_ratingsPath)) - { - Directory.CreateDirectory(_ratingsPath); - } - } - - return _ratingsPath; - } - } - - /// - /// The _user configuration directory path - /// - private string _userConfigurationDirectoryPath; - /// - /// Gets the path to the user configuration directory - /// - /// The user configuration directory path. - public string UserConfigurationDirectoryPath - { - get - { - if (_userConfigurationDirectoryPath == null) - { - _userConfigurationDirectoryPath = Path.Combine(ConfigurationDirectoryPath, "users"); - if (!Directory.Exists(_userConfigurationDirectoryPath)) - { - Directory.CreateDirectory(_userConfigurationDirectoryPath); - } - } - return _userConfigurationDirectoryPath; - } - } - - /// - /// The _f F MPEG stream cache path - /// - private string _fFMpegStreamCachePath; - /// - /// Gets the FF MPEG stream cache path. - /// - /// The FF MPEG stream cache path. - public string FFMpegStreamCachePath - { - get - { - if (_fFMpegStreamCachePath == null) - { - _fFMpegStreamCachePath = Path.Combine(CachePath, "ffmpeg-streams"); - - if (!Directory.Exists(_fFMpegStreamCachePath)) - { - Directory.CreateDirectory(_fFMpegStreamCachePath); - } - } - - return _fFMpegStreamCachePath; - } - } - - /// - /// The _media tools path - /// - private string _mediaToolsPath; - /// - /// Gets the folder path to tools - /// - /// The media tools path. - public string MediaToolsPath - { - get - { - if (_mediaToolsPath == null) - { - _mediaToolsPath = Path.Combine(ProgramDataPath, "MediaTools"); - - if (!Directory.Exists(_mediaToolsPath)) - { - Directory.CreateDirectory(_mediaToolsPath); - } - } - - return _mediaToolsPath; - } - } - } -} diff --git a/MediaBrowser.Controller/Updates/InstallationManager.cs b/MediaBrowser.Controller/Updates/InstallationManager.cs index bef5a6472..af544dd51 100644 --- a/MediaBrowser.Controller/Updates/InstallationManager.cs +++ b/MediaBrowser.Controller/Updates/InstallationManager.cs @@ -1,18 +1,17 @@ -using System.Security.Cryptography; -using MediaBrowser.Common.Events; -using MediaBrowser.Common.Kernel; +using MediaBrowser.Common.Events; using MediaBrowser.Common.Net; using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Progress; -using MediaBrowser.Common.Serialization; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Updates; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; @@ -32,8 +31,8 @@ namespace MediaBrowser.Controller.Updates /// /// The completed installations /// - public readonly ConcurrentBag CompletedInstallations = new ConcurrentBag(); - + public readonly ConcurrentBag CompletedInstallations = new ConcurrentBag(); + #region PluginUninstalled Event /// /// Occurs when [plugin uninstalled]. @@ -68,7 +67,7 @@ namespace MediaBrowser.Controller.Updates _logger.Info("Plugin updated: {0} {1} {2}", newVersion.name, newVersion.version, newVersion.classification); EventHelper.QueueEventIfNotNull(PluginUpdated, this, new GenericEventArgs> { Argument = new Tuple(plugin, newVersion) }, _logger); - + Kernel.NotifyPendingRestart(); } #endregion @@ -108,15 +107,22 @@ namespace MediaBrowser.Controller.Updates /// private readonly INetworkManager _networkManager; + /// + /// Gets the json serializer. + /// + /// The json serializer. + protected IJsonSerializer JsonSerializer { get; private set; } + /// /// Initializes a new instance of the class. /// /// The kernel. /// The zip client. /// The network manager. + /// /// The logger. /// zipClient - public InstallationManager(Kernel kernel, IZipClient zipClient, INetworkManager networkManager, ILogger logger) + public InstallationManager(Kernel kernel, IZipClient zipClient, INetworkManager networkManager, IJsonSerializer jsonSerializer, ILogger logger) : base(kernel) { if (zipClient == null) @@ -131,6 +137,12 @@ namespace MediaBrowser.Controller.Updates { throw new ArgumentNullException("logger"); } + if (jsonSerializer == null) + { + throw new ArgumentNullException("jsonSerializer"); + } + + JsonSerializer = jsonSerializer; _networkManager = networkManager; _logger = logger; @@ -161,7 +173,7 @@ namespace MediaBrowser.Controller.Updates package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) .OrderByDescending(v => v.version).ToList(); } - + if (packageType.HasValue) { packages = packages.Where(p => p.type == packageType.Value).ToList(); @@ -178,7 +190,7 @@ namespace MediaBrowser.Controller.Updates // Remove packages with no versions packages = packages.Where(p => p.versions.Any()).ToList(); - + return packages; } } @@ -320,7 +332,7 @@ namespace MediaBrowser.Controller.Updates var innerCancellationTokenSource = new CancellationTokenSource(); var tuple = new Tuple(installationInfo, innerCancellationTokenSource); - + // Add it to the in-progress list lock (CurrentInstallations) { @@ -364,7 +376,7 @@ namespace MediaBrowser.Controller.Updates _logger.Info("Package installation cancelled: {0} {1}", package.name, package.versionStr); Kernel.TcpManager.SendWebSocketMessage("PackageInstallationCancelled", installationInfo); - + throw; } catch @@ -373,7 +385,7 @@ namespace MediaBrowser.Controller.Updates { CurrentInstallations.Remove(tuple); } - + Kernel.TcpManager.SendWebSocketMessage("PackageInstallationFailed", installationInfo); throw; @@ -421,7 +433,7 @@ namespace MediaBrowser.Controller.Updates } cancellationToken.ThrowIfCancellationRequested(); - + // Success - move it to the real target based on type if (isArchive) { @@ -435,7 +447,7 @@ namespace MediaBrowser.Controller.Updates throw; } - } + } else { try @@ -448,8 +460,8 @@ namespace MediaBrowser.Controller.Updates _logger.ErrorException("Error attempting to move file from {0} to {1}", e, tempFile, target); throw; } - } - + } + // Set last update time if we were installed before var plugin = Kernel.Plugins.FirstOrDefault(p => p.Name.Equals(package.name, StringComparison.OrdinalIgnoreCase)); -- cgit v1.2.3