aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common
diff options
context:
space:
mode:
authorhatharry <hatharry@hotmail.com>2016-08-29 01:27:43 +1200
committerhatharry <hatharry@hotmail.com>2016-08-29 01:27:43 +1200
commitcabf2cdc1be4c06714ac6bcf835a19d2f652a6e2 (patch)
treed375b8a41e9fd40a2569ceea6b02e4f8237db797 /MediaBrowser.Server.Startup.Common
parente564b54686029a90595e1bb4277f87490763e183 (diff)
parentc974641a352685b2e6595dd7b291843c8e6364ac (diff)
Merge branch 'dev' of https://github.com/hatharry/Emby.git
Diffstat (limited to 'MediaBrowser.Server.Startup.Common')
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs52
-rw-r--r--MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs2
-rw-r--r--MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj3
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/CollectionGroupingMigration.cs44
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/CollectionsViewMigration.cs6
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs40
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs108
7 files changed, 121 insertions, 134 deletions
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index b7ea5bdad..9c5015b0e 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -101,6 +101,7 @@ using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
+using MediaBrowser.Api.Playback;
using MediaBrowser.Common.Implementations.Updates;
namespace MediaBrowser.Server.Startup.Common
@@ -362,9 +363,7 @@ namespace MediaBrowser.Server.Startup.Common
private void PerformPreInitMigrations()
{
- var migrations = new List<IVersionMigration>
- {
- };
+ var migrations = new List<IVersionMigration>();
foreach (var task in migrations)
{
@@ -386,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)
};
@@ -608,7 +606,7 @@ namespace MediaBrowser.Server.Startup.Common
{
return new ImageMagickEncoder(LogManager.GetLogger("ImageMagick"), ApplicationPaths, HttpClient, FileSystemManager, ServerConfigurationManager);
}
- catch (Exception ex)
+ catch
{
Logger.Error("Error loading ImageMagick. Will revert to GDI.");
}
@@ -618,7 +616,7 @@ namespace MediaBrowser.Server.Startup.Common
{
return new GDIImageEncoder(FileSystemManager, LogManager.GetLogger("GDI"));
}
- catch (Exception ex)
+ catch
{
Logger.Error("Error loading GDI. Will revert to NullImageEncoder.");
}
@@ -767,6 +765,9 @@ namespace MediaBrowser.Server.Startup.Common
UserView.PlaylistManager = PlaylistManager;
BaseItem.CollectionManager = CollectionManager;
BaseItem.MediaSourceManager = MediaSourceManager;
+ CollectionFolder.XmlSerializer = XmlSerializer;
+ BaseStreamingService.AppHost = this;
+ BaseStreamingService.HttpClient = HttpClient;
}
/// <summary>
@@ -822,42 +823,11 @@ namespace MediaBrowser.Server.Startup.Common
private string CertificatePath { get; set; }
- private string NormalizeConfiguredLocalAddress(string address)
- {
- var index = address.Trim('/').IndexOf('/');
-
- if (index != -1)
- {
- address = address.Substring(index + 1);
- }
-
- return address.Trim('/');
- }
private IEnumerable<string> GetUrlPrefixes()
{
- var hosts = ServerConfigurationManager
- .Configuration
- .LocalNetworkAddresses
- .Select(NormalizeConfiguredLocalAddress)
- .ToList();
-
- if (hosts.Count == 0)
- {
- hosts.Add("+");
- }
-
- if (!hosts.Contains("+", StringComparer.OrdinalIgnoreCase))
- {
- if (!hosts.Contains("localhost", StringComparer.OrdinalIgnoreCase))
- {
- hosts.Add("localhost");
- }
+ var hosts = new List<string>();
- if (!hosts.Contains("127.0.0.1", StringComparer.OrdinalIgnoreCase))
- {
- hosts.Add("127.0.0.1");
- }
- }
+ hosts.Add("+");
return hosts.SelectMany(i =>
{
@@ -1414,7 +1384,7 @@ namespace MediaBrowser.Server.Startup.Common
{
return new Uri(externalDns).Host;
}
- catch (Exception e)
+ catch
{
return externalDns;
}
diff --git a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs
index db48d1110..6b3602a73 100644
--- a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs
+++ b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs
@@ -1,7 +1,5 @@
using MediaBrowser.Controller;
-using MediaBrowser.Model.Logging;
using System;
-using System.Diagnostics;
namespace MediaBrowser.Server.Startup.Common.Browser
{
diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
index 808d25fc9..5ee7d49e8 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 b497eeb42..000000000
--- a/MediaBrowser.Server.Startup.Common/Migrations/CollectionGroupingMigration.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-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/CollectionsViewMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/CollectionsViewMigration.cs
index c6186ce08..3f68ec48b 100644
--- a/MediaBrowser.Server.Startup.Common/Migrations/CollectionsViewMigration.cs
+++ b/MediaBrowser.Server.Startup.Common/Migrations/CollectionsViewMigration.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Linq;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs b/MediaBrowser.Server.Startup.Common/Migrations/FolderViewSettingMigration.cs
deleted file mode 100644
index 12054864b..000000000
--- 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 000000000..ec00fb33d
--- /dev/null
+++ b/MediaBrowser.Server.Startup.Common/Migrations/UpdateLevelMigration.cs
@@ -0,0 +1,108 @@
+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;
+
+ 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 releases = await new GithubUpdater(_httpClient, _jsonSerializer, TimeSpan.FromMinutes(5))
+ .GetLatestReleases("MediaBrowser", "Emby", _releaseAssetFilename, cancellationToken).ConfigureAwait(false);
+
+ var newUpdateLevel = updateLevel;
+
+ // If the current version is later than current stable, set the update level to beta
+ if (releases.Count >= 1)
+ {
+ var release = releases[0];
+ var version = ParseVersion(release.tag_name);
+ if (version != null && currentVersion > version)
+ {
+ newUpdateLevel = PackageVersionClass.Beta;
+ }
+ }
+
+ // If the current version is later than current beta, set the update level to dev
+ if (releases.Count >= 2)
+ {
+ var release = releases[1];
+ var version = ParseVersion(release.tag_name);
+ if (version != null && currentVersion > version)
+ {
+ newUpdateLevel = PackageVersionClass.Dev;
+ }
+ }
+
+ if (newUpdateLevel != updateLevel)
+ {
+ _config.Configuration.SystemUpdateLevel = newUpdateLevel;
+ _config.SaveConfiguration();
+ }
+ }
+
+ private Version ParseVersion(string versionString)
+ {
+ var parts = versionString.Split('.');
+ if (parts.Length == 3)
+ {
+ versionString += ".0";
+ }
+
+ Version version;
+ Version.TryParse(versionString, out version);
+
+ return version;
+ }
+ }
+}