commit
1ccab75cd0
|
@ -174,9 +174,15 @@ namespace Emby.Common.Implementations
|
|||
}
|
||||
}
|
||||
|
||||
public virtual PackageVersionClass SystemUpdateLevel
|
||||
public PackageVersionClass SystemUpdateLevel
|
||||
{
|
||||
get { return PackageVersionClass.Release; }
|
||||
get {
|
||||
|
||||
#if BETA
|
||||
return PackageVersionClass.Beta;
|
||||
#endif
|
||||
return PackageVersionClass.Release;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string OperatingSystemDisplayName
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Model.Updates;
|
||||
|
||||
namespace Emby.Server.Core
|
||||
{
|
||||
public static class UpdateLevelHelper
|
||||
{
|
||||
public static PackageVersionClass GetSystemUpdateLevel(IConfigurationManager config)
|
||||
{
|
||||
return config.CommonConfiguration.SystemUpdateLevel;
|
||||
//var configuredValue = ConfigurationManager.AppSettings["SystemUpdateLevel"];
|
||||
|
||||
//if (string.Equals(configuredValue, "Beta", StringComparison.OrdinalIgnoreCase))
|
||||
//{
|
||||
// return PackageVersionClass.Beta;
|
||||
//}
|
||||
//if (string.Equals(configuredValue, "Dev", StringComparison.OrdinalIgnoreCase))
|
||||
//{
|
||||
// return PackageVersionClass.Dev;
|
||||
//}
|
||||
|
||||
//return PackageVersionClass.Release;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Updates;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Updates;
|
||||
|
||||
namespace Emby.Server.Implementations.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;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
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 Task 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;
|
||||
|
||||
await CheckVersion(currentVersion, updateLevel, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error in update migration", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CheckVersion(Version currentVersion, PackageVersionClass currentUpdateLevel, CancellationToken cancellationToken)
|
||||
{
|
||||
var releases = await new GithubUpdater(_httpClient, _jsonSerializer)
|
||||
.GetLatestReleases("MediaBrowser", "Emby", _releaseAssetFilename, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var newUpdateLevel = GetNewUpdateLevel(currentVersion, currentUpdateLevel, releases);
|
||||
|
||||
if (newUpdateLevel != currentUpdateLevel)
|
||||
{
|
||||
_config.Configuration.SystemUpdateLevel = newUpdateLevel;
|
||||
_config.SaveConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
private PackageVersionClass GetNewUpdateLevel(Version currentVersion, PackageVersionClass currentUpdateLevel, List<GithubUpdater.RootObject> releases)
|
||||
{
|
||||
var newUpdateLevel = currentUpdateLevel;
|
||||
|
||||
// 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)
|
||||
{
|
||||
if (currentVersion > version)
|
||||
{
|
||||
newUpdateLevel = PackageVersionClass.Beta;
|
||||
}
|
||||
else
|
||||
{
|
||||
return PackageVersionClass.Release;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
if (currentVersion > version)
|
||||
{
|
||||
newUpdateLevel = PackageVersionClass.Dev;
|
||||
}
|
||||
else
|
||||
{
|
||||
return PackageVersionClass.Beta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newUpdateLevel;
|
||||
}
|
||||
|
||||
private Version ParseVersion(string versionString)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(versionString))
|
||||
{
|
||||
var parts = versionString.Split('.');
|
||||
if (parts.Length == 3)
|
||||
{
|
||||
versionString += ".0";
|
||||
}
|
||||
}
|
||||
|
||||
Version version;
|
||||
Version.TryParse(versionString, out version);
|
||||
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -131,7 +131,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
/// Creates the name of the sort.
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
protected override string CreateSortName()
|
||||
protected override string CreateSortNameInternal()
|
||||
{
|
||||
return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("0000 - ") : "")
|
||||
+ (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ") : "") + Name;
|
||||
|
|
|
@ -689,14 +689,22 @@ namespace MediaBrowser.Controller.Entities
|
|||
return System.IO.Path.Combine(basePath, idString.Substring(0, 2), idString);
|
||||
}
|
||||
|
||||
protected string CreateSortName()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return CreateSortNameInternal();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the name of the sort.
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
protected virtual string CreateSortName()
|
||||
protected virtual string CreateSortNameInternal()
|
||||
{
|
||||
if (Name == null) return null; //some items may not have name filled in properly
|
||||
|
||||
if (!EnableAlphaNumericSorting)
|
||||
{
|
||||
return Name.TrimStart();
|
||||
|
|
|
@ -237,7 +237,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
/// Creates the name of the sort.
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
protected override string CreateSortName()
|
||||
protected override string CreateSortNameInternal()
|
||||
{
|
||||
return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("000 - ") : "")
|
||||
+ (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ") : "") + Name;
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
/// Creates the name of the sort.
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
protected override string CreateSortName()
|
||||
protected override string CreateSortNameInternal()
|
||||
{
|
||||
return IndexNumber != null ? IndexNumber.Value.ToString("0000") : Name;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace MediaBrowser.Controller.LiveTv
|
|||
}
|
||||
}
|
||||
|
||||
protected override string CreateSortName()
|
||||
protected override string CreateSortNameInternal()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Number))
|
||||
{
|
||||
|
|
|
@ -21,11 +21,6 @@ namespace MediaBrowser.Model.Configuration
|
|||
/// <value><c>true</c> if [enable auto update]; otherwise, <c>false</c>.</value>
|
||||
public bool EnableAutoUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets of sets a value indicating the level of system updates (Release, Beta, Dev)
|
||||
/// </summary>
|
||||
public PackageVersionClass SystemUpdateLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of days we should retain log files
|
||||
/// </summary>
|
||||
|
|
|
@ -42,11 +42,6 @@ namespace MediaBrowser.Server.Mono
|
|||
return new SyncManager();
|
||||
}
|
||||
|
||||
public override PackageVersionClass SystemUpdateLevel
|
||||
{
|
||||
get { return UpdateLevelHelper.GetSystemUpdateLevel(ConfigurationManager); }
|
||||
}
|
||||
|
||||
protected override void RestartInternal()
|
||||
{
|
||||
MainClass.Restart(StartupOptions);
|
||||
|
|
|
@ -55,11 +55,6 @@ namespace MediaBrowser.ServerApplication
|
|||
LoopUtil.Run(appName);
|
||||
}
|
||||
|
||||
public override PackageVersionClass SystemUpdateLevel
|
||||
{
|
||||
get { return UpdateLevelHelper.GetSystemUpdateLevel(ConfigurationManager); }
|
||||
}
|
||||
|
||||
protected override List<Assembly> GetAssembliesWithPartsInternal()
|
||||
{
|
||||
var list = new List<Assembly>();
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("3.2.17.19")]
|
||||
[assembly: AssemblyVersion("3.2.17.20")]
|
||||
|
|
Loading…
Reference in New Issue
Block a user