Merge pull request #2147 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-09-09 03:00:03 -04:00 committed by GitHub
commit 11f5b9db96
6 changed files with 21 additions and 59 deletions

View File

@ -14,16 +14,14 @@ namespace MediaBrowser.Common.Implementations.Updates
{
private readonly IHttpClient _httpClient;
private readonly IJsonSerializer _jsonSerializer;
private TimeSpan _cacheLength;
public GithubUpdater(IHttpClient httpClient, IJsonSerializer jsonSerializer, TimeSpan cacheLength)
public GithubUpdater(IHttpClient httpClient, IJsonSerializer jsonSerializer)
{
_httpClient = httpClient;
_jsonSerializer = jsonSerializer;
_cacheLength = cacheLength;
}
public async Task<CheckForUpdateResult> CheckForUpdateResult(string organzation, string repository, Version minVersion, PackageVersionClass updateLevel, 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, TimeSpan cacheLength, CancellationToken cancellationToken)
{
var url = string.Format("https://api.github.com/repos/{0}/{1}/releases", organzation, repository);
@ -35,10 +33,10 @@ namespace MediaBrowser.Common.Implementations.Updates
UserAgent = "Emby/3.0"
};
if (_cacheLength.Ticks > 0)
if (cacheLength.Ticks > 0)
{
options.CacheMode = CacheMode.Unconditional;
options.CacheLength = _cacheLength;
options.CacheLength = cacheLength;
}
using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
@ -110,12 +108,6 @@ namespace MediaBrowser.Common.Implementations.Updates
UserAgent = "Emby/3.0"
};
if (_cacheLength.Ticks > 0)
{
options.CacheMode = CacheMode.Unconditional;
options.CacheLength = _cacheLength;
}
using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
{
var obj = _jsonSerializer.DeserializeFromStream<RootObject[]>(stream);

View File

@ -194,14 +194,22 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
return station;
}
if (string.IsNullOrWhiteSpace(channelName))
if (!string.IsNullOrWhiteSpace(channelName))
{
return null;
}
channelName = NormalizeName(channelName);
return channelPair.Values.FirstOrDefault(i => string.Equals(NormalizeName(i.callsign ?? string.Empty), channelName, StringComparison.OrdinalIgnoreCase));
var result = channelPair.Values.FirstOrDefault(i => string.Equals(NormalizeName(i.callsign ?? string.Empty), channelName, StringComparison.OrdinalIgnoreCase));
if (result != null)
{
return result;
}
}
if (!string.IsNullOrWhiteSpace(channelNumber))
{
return channelPair.Values.FirstOrDefault(i => string.Equals(NormalizeName(i.stationID ?? string.Empty), channelNumber, StringComparison.OrdinalIgnoreCase));
}
}
return null;

View File

@ -1345,8 +1345,8 @@ namespace MediaBrowser.Server.Startup.Common
cacheLength = TimeSpan.FromMinutes(5);
}
var result = await new GithubUpdater(HttpClient, JsonSerializer, cacheLength).CheckForUpdateResult("MediaBrowser", "Emby", ApplicationVersion, updateLevel, _releaseAssetFilename,
"MBServer", "Mbserver.zip", cancellationToken).ConfigureAwait(false);
var result = await new GithubUpdater(HttpClient, JsonSerializer).CheckForUpdateResult("MediaBrowser", "Emby", ApplicationVersion, updateLevel, _releaseAssetFilename,
"MBServer", "Mbserver.zip", cacheLength, cancellationToken).ConfigureAwait(false);
HasUpdateAvailable = result.IsUpdateAvailable;

View File

@ -52,7 +52,7 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
private async Task CheckVersion(Version currentVersion, PackageVersionClass currentUpdateLevel, CancellationToken cancellationToken)
{
var releases = await new GithubUpdater(_httpClient, _jsonSerializer, TimeSpan.FromMinutes(3))
var releases = await new GithubUpdater(_httpClient, _jsonSerializer)
.GetLatestReleases("MediaBrowser", "Emby", _releaseAssetFilename, cancellationToken).ConfigureAwait(false);
var newUpdateLevel = GetNewUpdateLevel(currentVersion, currentUpdateLevel, releases);

View File

@ -217,7 +217,7 @@ namespace MediaBrowser.ServerApplication.Native
return false;
}
return MessageBox.Show(MainStartup._splash, "Emby has detected that Windows Firewall has been configured in a way that may prevent your other devices from accessing Emby Server. Click OK to remove this rule, or cancel to proceed anyway.", "Windows Firewall", MessageBoxButtons.OKCancel) == DialogResult.OK;
return MessageBox.Show(MainStartup._splash, "Emby has detected that a rule has been added to Windows Firewall that may prevent your other devices from accessing Emby Server. Click OK to remove this rule, or cancel to proceed anyway.", "Windows Firewall", MessageBoxButtons.OKCancel) == DialogResult.OK;
}
public bool PortsRequireAuthorization(string applicationPath)

View File

@ -58,11 +58,6 @@ namespace MediaBrowser.WebDashboard.Api
{
}
[Route("/web/staticfiles", "GET")]
public class GetCacheFiles
{
}
/// <summary>
/// Class GetDashboardResource
/// </summary>
@ -145,37 +140,6 @@ namespace MediaBrowser.WebDashboard.Api
return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml("dummy.html", page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false));
}
public object Get(GetCacheFiles request)
{
var allFiles = GetCacheFileList();
return ResultFactory.GetOptimizedResult(Request, _jsonSerializer.SerializeToString(allFiles));
}
private List<string> GetCacheFileList()
{
var creator = GetPackageCreator();
var directory = creator.DashboardUIPath;
var skipExtensions = GetDeployIgnoreExtensions();
var skipNames = GetDeployIgnoreFilenames();
return
Directory.GetFiles(directory, "*", SearchOption.AllDirectories)
.Where(i => !skipExtensions.Contains(Path.GetExtension(i) ?? string.Empty, StringComparer.OrdinalIgnoreCase))
.Where(i => !skipNames.Any(s =>
{
if (s.Item2)
{
return string.Equals(s.Item1, Path.GetFileName(i), StringComparison.OrdinalIgnoreCase);
}
return (Path.GetFileName(i) ?? string.Empty).IndexOf(s.Item1, StringComparison.OrdinalIgnoreCase) != -1;
}))
.Select(i => i.Replace(directory, string.Empty, StringComparison.OrdinalIgnoreCase).Replace("\\", "/").TrimStart('/') + "?v=" + _appHost.ApplicationVersion.ToString())
.ToList();
}
/// <summary>
/// Gets the specified request.
/// </summary>
@ -369,8 +333,6 @@ namespace MediaBrowser.WebDashboard.Api
var appVersion = _appHost.ApplicationVersion.ToString();
File.WriteAllText(Path.Combine(path, "staticfiles"), _jsonSerializer.SerializeToString(GetCacheFileList()));
var mode = request.Mode;
// Try to trim the output size a bit