|
|
@ -25,7 +25,7 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|
|
|
_cacheLength = cacheLength;
|
|
|
|
_cacheLength = cacheLength;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<CheckForUpdateResult> CheckForUpdateResult(string organzation, string repository, Version minVersion, bool includePrerelease, string[] excludeSuffixes, string assetFilename, string packageName, string targetFilename, CancellationToken cancellationToken)
|
|
|
|
public async Task<CheckForUpdateResult> CheckForUpdateResult(string organzation, string repository, Version minVersion, PackageVersionClass updateLevel, string assetFilename, string packageName, string targetFilename, CancellationToken cancellationToken)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var url = string.Format("https://api.github.com/repos/{0}/{1}/releases", organzation, repository);
|
|
|
|
var url = string.Format("https://api.github.com/repos/{0}/{1}/releases", organzation, repository);
|
|
|
|
|
|
|
|
|
|
|
@ -44,42 +44,31 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|
|
|
options.CacheLength = _cacheLength;
|
|
|
|
options.CacheLength = _cacheLength;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (var stream = await _httpClient.Get(new HttpRequestOptions
|
|
|
|
using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
|
|
|
|
{
|
|
|
|
|
|
|
|
Url = url,
|
|
|
|
|
|
|
|
EnableKeepAlive = false,
|
|
|
|
|
|
|
|
CancellationToken = cancellationToken,
|
|
|
|
|
|
|
|
UserAgent = "Emby/3.0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).ConfigureAwait(false))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var obj = _jsonSerializer.DeserializeFromStream<RootObject[]>(stream);
|
|
|
|
var obj = _jsonSerializer.DeserializeFromStream<RootObject[]>(stream);
|
|
|
|
|
|
|
|
|
|
|
|
var availableUpdate = CheckForUpdateResult(obj, minVersion, includePrerelease, excludeSuffixes, assetFilename, packageName, targetFilename);
|
|
|
|
return CheckForUpdateResult(obj, minVersion, updateLevel, assetFilename, packageName, targetFilename);
|
|
|
|
|
|
|
|
|
|
|
|
return availableUpdate ?? new CheckForUpdateResult
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IsUpdateAvailable = false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private CheckForUpdateResult CheckForUpdateResult(RootObject[] obj, Version minVersion, bool includePrerelease, string[] excludeSuffixes, string assetFilename, string packageName, string targetFilename)
|
|
|
|
private CheckForUpdateResult CheckForUpdateResult(RootObject[] obj, Version minVersion, PackageVersionClass updateLevel, string assetFilename, string packageName, string targetFilename)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!includePrerelease)
|
|
|
|
if (updateLevel == PackageVersionClass.Release)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
obj = obj.Where(i => !i.prerelease).ToArray();
|
|
|
|
obj = obj.Where(i => !i.prerelease).ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (updateLevel == PackageVersionClass.Beta)
|
|
|
|
if (excludeSuffixes.Length > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
obj = obj.Where(i => !excludeSuffixes.Any(e => i.name.EndsWith(e, StringComparison.OrdinalIgnoreCase))).ToArray();
|
|
|
|
obj = obj.Where(i => !i.prerelease || !i.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase)).ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
var availableUpdate = obj.Select(i => CheckForUpdateResult(i, minVersion, assetFilename, packageName, targetFilename)).FirstOrDefault(i => i != null);
|
|
|
|
// Filter using name and check for suffixes such as -beta, -dev?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return obj.Select(i => CheckForUpdateResult(i, minVersion, assetFilename, packageName, targetFilename)).FirstOrDefault(i => i != null);
|
|
|
|
return availableUpdate ?? new CheckForUpdateResult
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IsUpdateAvailable = false
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private CheckForUpdateResult CheckForUpdateResult(RootObject obj, Version minVersion, string assetFilename, string packageName, string targetFilename)
|
|
|
|
private CheckForUpdateResult CheckForUpdateResult(RootObject obj, Version minVersion, string assetFilename, string packageName, string targetFilename)
|
|
|
@ -108,7 +97,9 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|
|
|
IsUpdateAvailable = version > minVersion,
|
|
|
|
IsUpdateAvailable = version > minVersion,
|
|
|
|
Package = new PackageVersionInfo
|
|
|
|
Package = new PackageVersionInfo
|
|
|
|
{
|
|
|
|
{
|
|
|
|
classification = obj.prerelease ? PackageVersionClass.Beta : PackageVersionClass.Release,
|
|
|
|
classification = obj.prerelease ?
|
|
|
|
|
|
|
|
(obj.name.EndsWith("-dev", StringComparison.OrdinalIgnoreCase) ? PackageVersionClass.Dev : PackageVersionClass.Beta) :
|
|
|
|
|
|
|
|
PackageVersionClass.Release,
|
|
|
|
name = packageName,
|
|
|
|
name = packageName,
|
|
|
|
sourceUrl = asset.browser_download_url,
|
|
|
|
sourceUrl = asset.browser_download_url,
|
|
|
|
targetFilename = targetFilename,
|
|
|
|
targetFilename = targetFilename,
|
|
|
|