The Free Software Media System - Server Backend & API
update startup tasks
Luke Pulverenti5cfae1ada111
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.csindex 13d5597738..98bef334b7 100644--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs@@ -602,7 +602,7 @@ namespace MediaBrowser.Model.Dlnaprivate int GetAudioBitrate(string subProtocol, int? maxTotalBitrate, int? targetAudioChannels, string targetAudioCodec, MediaStream audioStream){- var defaultBitrate = audioStream == null ? 192000 : audioStream.BitRate ?? 192000;+ int defaultBitrate = audioStream == null ? 192000 : audioStream.BitRate ?? 192000;// Reduce the bitrate if we're downmixingif (targetAudioChannels.HasValue && audioStream != null && audioStream.Channels.HasValue && targetAudioChannels.Value < audioStream.Channels.Value){@@ -615,7 +615,7 @@ namespace MediaBrowser.Model.Dlna{if (StringHelper.EqualsIgnoreCase(targetAudioCodec, "ac3")){- if (string.Equals(subProtocol, "hls", StringComparison.OrdinalIgnoreCase))+ if (StringHelper.EqualsIgnoreCase(subProtocol, "hls")){defaultBitrate = Math.Max(384000, defaultBitrate);}diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex b3ced55a51..65d023e889 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -1011,7 +1011,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvvar factorChannelWatchCount = (query.IsAiring ?? false) || (query.IsKids ?? false) || (query.IsSports ?? false) || (query.IsMovie ?? false);- programs = programList.OrderBy(i => i.HasImage(ImageType.Primary) ? 0 : 1)+ programs = programList.OrderBy(i => i.StartDate.Date).ThenByDescending(i => GetRecommendationScore(i, user.Id, factorChannelWatchCount)).ThenBy(i => i.StartDate);diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex f5419e5cff..d8d3614e61 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.CommonHttpPort = 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.csindex f0cb9e84ee..6bcdcca879 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 nowif (_config.Configuration.MigrationVersion < CleanDatabaseScheduledTask.MigrationVersion)diff --git a/MediaBrowser.Server.Startup.Common/Migrations/IVersionMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/IVersionMigration.csindex a6a8c1a356..6ef08fae97 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.csindex 3ad5f577f3..cd2122e57b 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();