update github updater
This commit is contained in:
parent
ed66d1a80c
commit
1b50cd00ec
|
@ -25,7 +25,7 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
_cacheLength = cacheLength;
|
||||
}
|
||||
|
||||
public async Task<CheckForUpdateResult> CheckForUpdateResult(string organzation, string repository, Version minVersion, bool includePrerelease, string assetFilename, string packageName, string targetFilename, CancellationToken cancellationToken)
|
||||
public async Task<CheckForUpdateResult> CheckForUpdateResult(string organzation, string repository, Version minVersion, bool includePrerelease, string[] excludeSuffixes, string assetFilename, string packageName, string targetFilename, CancellationToken cancellationToken)
|
||||
{
|
||||
var url = string.Format("https://api.github.com/repos/{0}/{1}/releases", organzation, repository);
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
{
|
||||
var obj = _jsonSerializer.DeserializeFromStream<RootObject[]>(stream);
|
||||
|
||||
var availableUpdate = CheckForUpdateResult(obj, minVersion, includePrerelease, assetFilename, packageName, targetFilename);
|
||||
var availableUpdate = CheckForUpdateResult(obj, minVersion, includePrerelease, excludeSuffixes, assetFilename, packageName, targetFilename);
|
||||
|
||||
return availableUpdate ?? new CheckForUpdateResult
|
||||
{
|
||||
|
@ -64,13 +64,18 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
}
|
||||
}
|
||||
|
||||
private CheckForUpdateResult CheckForUpdateResult(RootObject[] obj, Version minVersion, bool includePrerelease, string assetFilename, string packageName, string targetFilename)
|
||||
private CheckForUpdateResult CheckForUpdateResult(RootObject[] obj, Version minVersion, bool includePrerelease, string[] excludeSuffixes, string assetFilename, string packageName, string targetFilename)
|
||||
{
|
||||
if (!includePrerelease)
|
||||
{
|
||||
obj = obj.Where(i => !i.prerelease).ToArray();
|
||||
}
|
||||
|
||||
if (excludeSuffixes.Length > 0)
|
||||
{
|
||||
obj = obj.Where(i => !excludeSuffixes.Any(e => i.name.EndsWith(e, StringComparison.OrdinalIgnoreCase))).ToArray();
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// Filter using name and check for suffixes such as -beta, -dev?
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace MediaBrowser.Server.Mono
|
|||
|
||||
var nativeApp = new NativeApp(options);
|
||||
|
||||
_appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "MBServer.Mono", nativeApp);
|
||||
_appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "emby.mono.zip", nativeApp);
|
||||
|
||||
if (options.ContainsOption("-v"))
|
||||
{
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
private IPlaylistManager PlaylistManager { get; set; }
|
||||
|
||||
private readonly StartupOptions _startupOptions;
|
||||
private readonly string _remotePackageName;
|
||||
private readonly string _releaseAssetFilename;
|
||||
|
||||
internal INativeApp NativeApp { get; set; }
|
||||
private Timer _ipAddressCacheTimer;
|
||||
|
@ -219,18 +219,18 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="remotePackageName">Name of the remote package.</param>
|
||||
/// <param name="releaseAssetFilename">The release asset filename.</param>
|
||||
/// <param name="nativeApp">The native application.</param>
|
||||
public ApplicationHost(ServerApplicationPaths applicationPaths,
|
||||
ILogManager logManager,
|
||||
StartupOptions options,
|
||||
IFileSystem fileSystem,
|
||||
string remotePackageName,
|
||||
string releaseAssetFilename,
|
||||
INativeApp nativeApp)
|
||||
: base(applicationPaths, logManager, fileSystem)
|
||||
{
|
||||
_startupOptions = options;
|
||||
_remotePackageName = remotePackageName;
|
||||
_releaseAssetFilename = releaseAssetFilename;
|
||||
NativeApp = nativeApp;
|
||||
|
||||
SetBaseExceptionMessage();
|
||||
|
@ -1301,36 +1301,31 @@ namespace MediaBrowser.Server.Startup.Common
|
|||
/// <returns>Task{CheckForUpdateResult}.</returns>
|
||||
public override async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
if (ConfigurationManager.CommonConfiguration.SystemUpdateLevel != PackageVersionClass.Dev)
|
||||
{
|
||||
var includePreRelease = ConfigurationManager.CommonConfiguration.SystemUpdateLevel != PackageVersionClass.Release;
|
||||
var includePreRelease = false;
|
||||
var cacheLength = TimeSpan.FromHours(12);
|
||||
var excludeSuffixes = new List<string>();
|
||||
|
||||
var cacheLength = TimeSpan.FromHours(1);
|
||||
if (ConfigurationManager.CommonConfiguration.SystemUpdateLevel == PackageVersionClass.Release)
|
||||
{
|
||||
// Shouldn't actually be needed due to the prerelease filter
|
||||
excludeSuffixes.Add("-beta");
|
||||
excludeSuffixes.Add("-dev");
|
||||
}
|
||||
else if (ConfigurationManager.CommonConfiguration.SystemUpdateLevel == PackageVersionClass.Beta)
|
||||
{
|
||||
excludeSuffixes.Add("-dev");
|
||||
cacheLength = TimeSpan.FromHours(1);
|
||||
includePreRelease = true;
|
||||
}
|
||||
else if (ConfigurationManager.CommonConfiguration.SystemUpdateLevel == PackageVersionClass.Dev)
|
||||
{
|
||||
excludeSuffixes.Add("-dev");
|
||||
cacheLength = TimeSpan.FromMinutes(5);
|
||||
includePreRelease = true;
|
||||
}
|
||||
|
||||
return await new GithubUpdater(HttpClient, JsonSerializer, cacheLength)
|
||||
.CheckForUpdateResult("MediaBrowser", "Emby", ApplicationVersion, includePreRelease, "emby.windows.zip", "MBServer", "Mbserver.zip", cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, _remotePackageName, null, ApplicationVersion, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
||||
|
||||
var versionObject = version == null || string.IsNullOrWhiteSpace(version.versionStr) ? null : new Version(version.versionStr);
|
||||
|
||||
var isUpdateAvailable = versionObject != null && versionObject > ApplicationVersion;
|
||||
|
||||
var result = versionObject != null ?
|
||||
new CheckForUpdateResult { AvailableVersion = versionObject.ToString(), IsUpdateAvailable = isUpdateAvailable, Package = version } :
|
||||
new CheckForUpdateResult { AvailableVersion = ApplicationVersion.ToString(), IsUpdateAvailable = false };
|
||||
|
||||
HasUpdateAvailable = result.IsUpdateAvailable;
|
||||
|
||||
if (result.IsUpdateAvailable)
|
||||
{
|
||||
Logger.Info("New application version is available: {0}", result.AvailableVersion);
|
||||
}
|
||||
|
||||
return result;
|
||||
.CheckForUpdateResult("MediaBrowser", "Emby", ApplicationVersion, includePreRelease, excludeSuffixes.ToArray(), _releaseAssetFilename, "MBServer", "Mbserver.zip", cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace MediaBrowser.ServerApplication
|
|||
logManager,
|
||||
options,
|
||||
fileSystem,
|
||||
"MBServer",
|
||||
"emby.windows.zip",
|
||||
nativeApp);
|
||||
|
||||
var initProgress = new Progress<double>();
|
||||
|
|
Loading…
Reference in New Issue
Block a user