aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Startup.Common')
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs3
-rw-r--r--MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj3
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/CollectionGroupingMigration.cs40
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs40
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs97
5 files changed, 99 insertions, 84 deletions
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 8cb1d4f0db..9c5015b0ec 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -385,8 +385,7 @@ namespace MediaBrowser.Server.Startup.Common
new OmdbEpisodeProviderMigration(ServerConfigurationManager),
new MovieDbEpisodeProviderMigration(ServerConfigurationManager),
new DbMigration(ServerConfigurationManager, TaskManager),
- new FolderViewSettingMigration(ServerConfigurationManager, UserManager),
- new CollectionGroupingMigration(ServerConfigurationManager, UserManager),
+ new UpdateLevelMigration(ServerConfigurationManager, this, HttpClient, JsonSerializer, _releaseAssetFilename),
new CollectionsViewMigration(ServerConfigurationManager, UserManager)
};
diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
index 808d25fc9c..5ee7d49e86 100644
--- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
+++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
@@ -70,13 +70,12 @@
<Compile Include="FFMpeg\FFMpegInfo.cs" />
<Compile Include="INativeApp.cs" />
<Compile Include="MbLinkShortcutHandler.cs" />
- <Compile Include="Migrations\CollectionGroupingMigration.cs" />
<Compile Include="Migrations\CollectionsViewMigration.cs" />
- <Compile Include="Migrations\FolderViewSettingMigration.cs" />
<Compile Include="Migrations\IVersionMigration.cs" />
<Compile Include="Migrations\DbMigration.cs" />
<Compile Include="Migrations\MovieDbEpisodeProviderMigration.cs" />
<Compile Include="Migrations\OmdbEpisodeProviderMigration.cs" />
+ <Compile Include="Migrations\UpdateLevelMigration.cs" />
<Compile Include="NativeEnvironment.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StartupOptions.cs" />
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/CollectionGroupingMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/CollectionGroupingMigration.cs
deleted file mode 100644
index 5041c49b8b..0000000000
--- a/MediaBrowser.Server.Startup.Common/Migrations/CollectionGroupingMigration.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System.Linq;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Library;
-
-namespace MediaBrowser.Server.Startup.Common.Migrations
-{
- public class CollectionGroupingMigration : IVersionMigration
- {
- private readonly IServerConfigurationManager _config;
- private readonly IUserManager _userManager;
-
- public CollectionGroupingMigration(IServerConfigurationManager config, IUserManager userManager)
- {
- _config = config;
- _userManager = userManager;
- }
-
- public void Run()
- {
- var migrationKey = this.GetType().Name;
- var migrationKeyList = _config.Configuration.Migrations.ToList();
-
- if (!migrationKeyList.Contains(migrationKey))
- {
- if (_config.Configuration.IsStartupWizardCompleted)
- {
- if (_userManager.Users.Any(i => i.Configuration.GroupMoviesIntoBoxSets))
- {
- _config.Configuration.EnableGroupingIntoCollections = true;
- }
- }
-
- migrationKeyList.Add(migrationKey);
- _config.Configuration.Migrations = migrationKeyList.ToArray();
- _config.SaveConfiguration();
- }
-
- }
- }
-}
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs
deleted file mode 100644
index 12054864b3..0000000000
--- a/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System.Linq;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Library;
-
-namespace MediaBrowser.Server.Startup.Common.Migrations
-{
- public class FolderViewSettingMigration : IVersionMigration
- {
- private readonly IServerConfigurationManager _config;
- private readonly IUserManager _userManager;
-
- public FolderViewSettingMigration(IServerConfigurationManager config, IUserManager userManager)
- {
- _config = config;
- _userManager = userManager;
- }
-
- public void Run()
- {
- var migrationKey = this.GetType().Name;
- var migrationKeyList = _config.Configuration.Migrations.ToList();
-
- if (!migrationKeyList.Contains(migrationKey))
- {
- if (_config.Configuration.IsStartupWizardCompleted)
- {
- if (_userManager.Users.Any(i => i.Configuration.DisplayFoldersView))
- {
- _config.Configuration.EnableFolderView = true;
- }
- }
-
- migrationKeyList.Add(migrationKey);
- _config.Configuration.Migrations = migrationKeyList.ToArray();
- _config.SaveConfiguration();
- }
-
- }
- }
-}
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs
new file mode 100644
index 0000000000..fa354065c3
--- /dev/null
+++ b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Common.Implementations.Updates;
+using MediaBrowser.Common.Net;
+using MediaBrowser.Controller;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Model.Serialization;
+using MediaBrowser.Model.Updates;
+
+namespace MediaBrowser.Server.Startup.Common.Migrations
+{
+ public class UpdateLevelMigration : IVersionMigration
+ {
+ private readonly IServerConfigurationManager _config;
+ private readonly IServerApplicationHost _appHost;
+ private readonly IHttpClient _httpClient;
+ private readonly IJsonSerializer _jsonSerializer;
+ private readonly string _releaseAssetFilename;
+
+ public UpdateLevelMigration(IServerConfigurationManager config, IServerApplicationHost appHost, IHttpClient httpClient, IJsonSerializer jsonSerializer, string releaseAssetFilename)
+ {
+ _config = config;
+ _appHost = appHost;
+ _httpClient = httpClient;
+ _jsonSerializer = jsonSerializer;
+ _releaseAssetFilename = releaseAssetFilename;
+ }
+
+ public async void Run()
+ {
+ var lastVersion = _config.Configuration.LastVersion;
+ var currentVersion = _appHost.ApplicationVersion;
+
+ if (string.Equals(lastVersion, currentVersion.ToString(), StringComparison.OrdinalIgnoreCase))
+ {
+ return;
+ }
+
+ try
+ {
+ var updateLevel = _config.Configuration.SystemUpdateLevel;
+
+ // Go down a level
+ if (updateLevel == PackageVersionClass.Release)
+ {
+ updateLevel = PackageVersionClass.Beta;
+ }
+ else if (updateLevel == PackageVersionClass.Beta)
+ {
+ updateLevel = PackageVersionClass.Dev;
+ }
+ else if (updateLevel == PackageVersionClass.Dev)
+ {
+ // It's already dev, there's nothing to check
+ return;
+ }
+
+ await CheckVersion(currentVersion, updateLevel, CancellationToken.None).ConfigureAwait(false);
+ }
+ catch
+ {
+
+ }
+ }
+
+ private async Task CheckVersion(Version currentVersion, PackageVersionClass updateLevel, CancellationToken cancellationToken)
+ {
+ var result = await new GithubUpdater(_httpClient, _jsonSerializer, TimeSpan.FromMinutes(5))
+ .CheckForUpdateResult("MediaBrowser", "Emby", currentVersion, PackageVersionClass.Beta, _releaseAssetFilename, "MBServer", "Mbserver.zip",
+ cancellationToken).ConfigureAwait(false);
+
+ if (result != null && result.IsUpdateAvailable)
+ {
+ _config.Configuration.SystemUpdateLevel = updateLevel;
+ _config.SaveConfiguration();
+ return;
+ }
+
+ // Go down a level
+ if (updateLevel == PackageVersionClass.Release)
+ {
+ updateLevel = PackageVersionClass.Beta;
+ }
+ else if (updateLevel == PackageVersionClass.Beta)
+ {
+ updateLevel = PackageVersionClass.Dev;
+ }
+ else
+ {
+ return;
+ }
+
+ await CheckVersion(currentVersion, updateLevel, cancellationToken).ConfigureAwait(false);
+ }
+ }
+}