aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-02-14 16:35:09 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-02-14 16:35:09 -0500
commitdaa0b6cd0ecefd60611752802d062c15e6da85de (patch)
treef58a16e47afed9b61471e3871280faa9fc8bd951 /MediaBrowser.Server.Startup.Common
parent7d26b8995f313917829573a7cd96c37decc9158a (diff)
parentfd5f12e76227d96c52cdc31b67ef9543b485169b (diff)
Merge branch 'beta'
Diffstat (limited to 'MediaBrowser.Server.Startup.Common')
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs41
-rw-r--r--MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs6
-rw-r--r--MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj3
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs36
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/OmdbEpisodeProviderMigration.cs47
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/Release5767.cs48
6 files changed, 114 insertions, 67 deletions
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 2d625f810..e61a64646 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -317,12 +317,20 @@ namespace MediaBrowser.Server.Startup.Common
/// <returns>Task.</returns>
public override async Task RunStartupTasks()
{
+ if (ServerConfigurationManager.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion &&
+ ServerConfigurationManager.Configuration.IsStartupWizardCompleted)
+ {
+ TaskManager.SuspendTriggers = true;
+ }
+
await base.RunStartupTasks().ConfigureAwait(false);
Logger.Info("ServerId: {0}", SystemId);
Logger.Info("Core startup complete");
HttpServer.GlobalResponse = null;
+ PerformPostInitMigrations();
+
Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint =>
{
try
@@ -336,8 +344,6 @@ namespace MediaBrowser.Server.Startup.Common
});
LogManager.RemoveConsoleOutput();
-
- PerformPostInitMigrations();
}
public override Task Init(IProgress<double> progress)
@@ -367,7 +373,8 @@ namespace MediaBrowser.Server.Startup.Common
{
var migrations = new List<IVersionMigration>
{
- new Release5767(ServerConfigurationManager, TaskManager)
+ new OmdbEpisodeProviderMigration(ServerConfigurationManager),
+ new DbMigration(ServerConfigurationManager, TaskManager)
};
foreach (var task in migrations)
@@ -423,7 +430,7 @@ namespace MediaBrowser.Server.Startup.Common
UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager);
RegisterSingleInstance(UserManager);
- LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager);
+ LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager, () => UserViewManager);
RegisterSingleInstance(LibraryManager);
var musicManager = new MusicManager(LibraryManager);
@@ -469,7 +476,7 @@ namespace MediaBrowser.Server.Startup.Common
ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager, SecurityManager, FileSystemManager);
RegisterSingleInstance(ConnectManager);
- DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager);
+ DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager);
RegisterSingleInstance(DeviceManager);
var newsService = new Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
@@ -507,7 +514,7 @@ namespace MediaBrowser.Server.Startup.Common
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);
RegisterSingleInstance(UserViewManager);
- var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager, MediaSourceManager);
+ var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager, MediaSourceManager, UserViewManager);
RegisterSingleInstance<IContentDirectory>(contentDirectory);
var mediaRegistrar = new MediaReceiverRegistrar(LogManager.GetLogger("MediaReceiverRegistrar"), HttpClient, ServerConfigurationManager);
@@ -646,11 +653,19 @@ namespace MediaBrowser.Server.Startup.Common
/// <returns>Task{IUserRepository}.</returns>
private async Task<IUserRepository> GetUserRepository()
{
- var repo = new SqliteUserRepository(LogManager, ApplicationPaths, JsonSerializer);
+ try
+ {
+ var repo = new SqliteUserRepository(LogManager, ApplicationPaths, JsonSerializer);
- await repo.Initialize().ConfigureAwait(false);
+ await repo.Initialize().ConfigureAwait(false);
- return repo;
+ return repo;
+ }
+ catch (Exception ex)
+ {
+ Logger.ErrorException("Error opening user db", ex);
+ throw;
+ }
}
/// <summary>
@@ -668,7 +683,7 @@ namespace MediaBrowser.Server.Startup.Common
private async Task<IAuthenticationRepository> GetAuthenticationRepository()
{
- var repo = new AuthenticationRepository(LogManager.GetLogger("AuthenticationRepository"), ServerConfigurationManager.ApplicationPaths);
+ var repo = new AuthenticationRepository(LogManager, ServerConfigurationManager.ApplicationPaths);
await repo.Initialize().ConfigureAwait(false);
@@ -677,7 +692,7 @@ namespace MediaBrowser.Server.Startup.Common
private async Task<IActivityRepository> GetActivityLogRepository()
{
- var repo = new ActivityRepository(LogManager.GetLogger("ActivityRepository"), ServerConfigurationManager.ApplicationPaths);
+ var repo = new ActivityRepository(LogManager, ServerConfigurationManager.ApplicationPaths);
await repo.Initialize().ConfigureAwait(false);
@@ -969,10 +984,6 @@ namespace MediaBrowser.Server.Startup.Common
{
get
{
- if (!ServerConfigurationManager.Configuration.EnableAutoUpdate)
- {
- return false;
- }
#if DEBUG
return false;
#endif
diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs
index b055c250b..3b83e65b2 100644
--- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs
+++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs
@@ -54,7 +54,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
info.FFMpegFilename = "ffmpeg.exe";
info.FFProbeFilename = "ffprobe.exe";
- info.Version = "20151111";
+ info.Version = "20160131";
info.ArchiveType = "7z";
switch (environment.SystemArchitecture)
@@ -83,13 +83,13 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
case Architecture.X86_X64:
return new[]
{
- "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20151111-win64.7z",
+ "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20160131-win64.7z",
"http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20151109-git-480bad7-win64-static.7z"
};
case Architecture.X86:
return new[]
{
- "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20151111-win32.7z",
+ "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20160131-win32.7z",
"http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20151109-git-480bad7-win32-static.7z"
};
}
diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
index 6dd2066bb..a4028d5b0 100644
--- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
+++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
@@ -72,7 +72,8 @@
<Compile Include="INativeApp.cs" />
<Compile Include="MbLinkShortcutHandler.cs" />
<Compile Include="Migrations\IVersionMigration.cs" />
- <Compile Include="Migrations\Release5767.cs" />
+ <Compile Include="Migrations\DbMigration.cs" />
+ <Compile Include="Migrations\OmdbEpisodeProviderMigration.cs" />
<Compile Include="Migrations\RenameXmlOptions.cs" />
<Compile Include="NativeEnvironment.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
new file mode 100644
index 000000000..3cd92bcde
--- /dev/null
+++ b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
@@ -0,0 +1,36 @@
+using System.Threading.Tasks;
+using MediaBrowser.Common.ScheduledTasks;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Server.Implementations.Persistence;
+
+namespace MediaBrowser.Server.Startup.Common.Migrations
+{
+ public class DbMigration : IVersionMigration
+ {
+ private readonly IServerConfigurationManager _config;
+ private readonly ITaskManager _taskManager;
+
+ public DbMigration(IServerConfigurationManager config, ITaskManager taskManager)
+ {
+ _config = config;
+ _taskManager = taskManager;
+ }
+
+ public void Run()
+ {
+ if (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion &&
+ _config.Configuration.IsStartupWizardCompleted)
+ {
+ _taskManager.SuspendTriggers = true;
+ CleanDatabaseScheduledTask.EnableUnavailableMessage = true;
+
+ Task.Run(async () =>
+ {
+ await Task.Delay(100).ConfigureAwait(false);
+
+ _taskManager.Execute<CleanDatabaseScheduledTask>();
+ });
+ }
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/OmdbEpisodeProviderMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/OmdbEpisodeProviderMigration.cs
new file mode 100644
index 000000000..00f6a692b
--- /dev/null
+++ b/MediaBrowser.Server.Startup.Common/Migrations/OmdbEpisodeProviderMigration.cs
@@ -0,0 +1,47 @@
+using MediaBrowser.Controller.Configuration;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Server.Startup.Common.Migrations
+{
+ class OmdbEpisodeProviderMigration : IVersionMigration
+ {
+ private readonly IServerConfigurationManager _config;
+ private const string _providerName = "The Open Movie Database";
+
+ public OmdbEpisodeProviderMigration(IServerConfigurationManager config)
+ {
+ _config = config;
+ }
+
+ public void Run()
+ {
+ var migrationKey = this.GetType().FullName;
+ var migrationKeyList = _config.Configuration.Migrations.ToList();
+
+ if (!migrationKeyList.Contains(migrationKey))
+ {
+ foreach (var metaDataOption in _config.Configuration.MetadataOptions)
+ {
+ if (metaDataOption.ItemType == "Episode")
+ {
+ var disabledFetchers = metaDataOption.DisabledMetadataFetchers.ToList();
+ if (!disabledFetchers.Contains(_providerName))
+ {
+ disabledFetchers.Add(_providerName);
+ metaDataOption.DisabledMetadataFetchers = disabledFetchers.ToArray();
+ }
+ }
+ }
+
+ migrationKeyList.Add(migrationKey);
+ _config.Configuration.Migrations = migrationKeyList.ToArray();
+ _config.SaveConfiguration();
+ }
+
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/Release5767.cs b/MediaBrowser.Server.Startup.Common/Migrations/Release5767.cs
deleted file mode 100644
index 168230b87..000000000
--- a/MediaBrowser.Server.Startup.Common/Migrations/Release5767.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using MediaBrowser.Common.ScheduledTasks;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Server.Implementations.LiveTv;
-using MediaBrowser.Server.Implementations.Persistence;
-using MediaBrowser.Server.Implementations.ScheduledTasks;
-
-namespace MediaBrowser.Server.Startup.Common.Migrations
-{
- public class Release5767 : IVersionMigration
- {
- private readonly IServerConfigurationManager _config;
- private readonly ITaskManager _taskManager;
-
- public Release5767(IServerConfigurationManager config, ITaskManager taskManager)
- {
- _config = config;
- _taskManager = taskManager;
- }
-
- public async void Run()
- {
- var name = "5767.1";
-
- if (_config.Configuration.Migrations.Contains(name, StringComparer.OrdinalIgnoreCase))
- {
- return;
- }
-
- Task.Run(async () =>
- {
- await Task.Delay(3000).ConfigureAwait(false);
-
- _taskManager.QueueScheduledTask<CleanDatabaseScheduledTask>();
- });
-
- // Wait a few minutes before marking this as done. Make sure the server doesn't get restarted.
- await Task.Delay(300000).ConfigureAwait(false);
-
- var list = _config.Configuration.Migrations.ToList();
- list.Add(name);
- _config.Configuration.Migrations = list.ToArray();
- _config.SaveConfiguration();
- }
- }
-}