aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-09-17 02:11:16 -0400
committerGitHub <noreply@github.com>2016-09-17 02:11:16 -0400
commit20739b144b5e7486d8b5fb0984aebca0de9e3284 (patch)
tree0faa8e2ab8e286791829a778b1c3b24c9857fdeb /MediaBrowser.Server.Startup.Common
parentbdc260d33b731cf82ae21248c661f24b856fd94b (diff)
parent5cfae1ada1114cb03561565c0e8a9d354e89562e (diff)
Merge pull request #2176 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Server.Startup.Common')
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs10
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs2
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/IVersionMigration.cs5
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/MovieDbEpisodeProviderMigration.cs3
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs20
5 files changed, 24 insertions, 16 deletions
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index f5419e5cf..d8d3614e6 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -315,6 +315,8 @@ namespace MediaBrowser.Server.Startup.Common
/// </summary>
public override async Task RunStartupTasks()
{
+ await PerformPreInitMigrations().ConfigureAwait(false);
+
if (ServerConfigurationManager.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion &&
ServerConfigurationManager.Configuration.IsStartupWizardCompleted)
{
@@ -366,23 +368,21 @@ namespace MediaBrowser.Server.Startup.Common
HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber;
HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber;
- PerformPreInitMigrations();
-
return base.Init(progress);
}
- private void PerformPreInitMigrations()
+ private async Task PerformPreInitMigrations()
{
var migrations = new List<IVersionMigration>
{
- new UpdateLevelMigration(ServerConfigurationManager, this, HttpClient, JsonSerializer, _releaseAssetFilename)
+ new UpdateLevelMigration(ServerConfigurationManager, this, HttpClient, JsonSerializer, _releaseAssetFilename, Logger)
};
foreach (var task in migrations)
{
try
{
- task.Run();
+ await task.Run().ConfigureAwait(false);
}
catch (Exception ex)
{
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
index f0cb9e84e..6bcdcca87 100644
--- a/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
+++ b/MediaBrowser.Server.Startup.Common/Migrations/DbMigration.cs
@@ -16,7 +16,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
_taskManager = taskManager;
}
- public void Run()
+ public async Task Run()
{
// If a forced migration is required, do that now
if (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion)
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/IVersionMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/IVersionMigration.cs
index a6a8c1a35..6ef08fae9 100644
--- a/MediaBrowser.Server.Startup.Common/Migrations/IVersionMigration.cs
+++ b/MediaBrowser.Server.Startup.Common/Migrations/IVersionMigration.cs
@@ -1,8 +1,9 @@
-
+using System.Threading.Tasks;
+
namespace MediaBrowser.Server.Startup.Common.Migrations
{
public interface IVersionMigration
{
- void Run();
+ Task Run();
}
}
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/MovieDbEpisodeProviderMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/MovieDbEpisodeProviderMigration.cs
index 3ad5f577f..cd2122e57 100644
--- a/MediaBrowser.Server.Startup.Common/Migrations/MovieDbEpisodeProviderMigration.cs
+++ b/MediaBrowser.Server.Startup.Common/Migrations/MovieDbEpisodeProviderMigration.cs
@@ -1,5 +1,6 @@
using MediaBrowser.Controller.Configuration;
using System.Linq;
+using System.Threading.Tasks;
namespace MediaBrowser.Server.Startup.Common.Migrations
{
@@ -13,7 +14,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
_config = config;
}
- public void Run()
+ public async Task Run()
{
var migrationKey = this.GetType().FullName;
var migrationKeyList = _config.Configuration.Migrations.ToList();
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs
index 4afd5bd34..8483ca904 100644
--- a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs
+++ b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs
@@ -6,6 +6,7 @@ using MediaBrowser.Common.Implementations.Updates;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Updates;
@@ -18,17 +19,19 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
private readonly IHttpClient _httpClient;
private readonly IJsonSerializer _jsonSerializer;
private readonly string _releaseAssetFilename;
+ private readonly ILogger _logger;
- public UpdateLevelMigration(IServerConfigurationManager config, IServerApplicationHost appHost, IHttpClient httpClient, IJsonSerializer jsonSerializer, string releaseAssetFilename)
+ public UpdateLevelMigration(IServerConfigurationManager config, IServerApplicationHost appHost, IHttpClient httpClient, IJsonSerializer jsonSerializer, string releaseAssetFilename, ILogger logger)
{
_config = config;
_appHost = appHost;
_httpClient = httpClient;
_jsonSerializer = jsonSerializer;
_releaseAssetFilename = releaseAssetFilename;
+ _logger = logger;
}
- public async void Run()
+ public async Task Run()
{
var lastVersion = _config.Configuration.LastVersion;
var currentVersion = _appHost.ApplicationVersion;
@@ -44,9 +47,9 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
await CheckVersion(currentVersion, updateLevel, CancellationToken.None).ConfigureAwait(false);
}
- catch
+ catch (Exception ex)
{
-
+ _logger.ErrorException("Error in update migration", ex);
}
}
@@ -109,10 +112,13 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
private Version ParseVersion(string versionString)
{
- var parts = versionString.Split('.');
- if (parts.Length == 3)
+ if (!string.IsNullOrWhiteSpace(versionString))
{
- versionString += ".0";
+ var parts = versionString.Split('.');
+ if (parts.Length == 3)
+ {
+ versionString += ".0";
+ }
}
Version version;