From 8a5198e6a395ed03fb471e62687fceecdf947abf Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sat, 19 Jan 2019 21:34:47 -0500 Subject: [PATCH 1/5] Remove ApplicationVersion --- Emby.Server.Implementations/ApplicationHost.cs | 9 +-------- MediaBrowser.Api/PackageService.cs | 6 +++--- MediaBrowser.Common/IApplicationHost.cs | 6 ------ 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index f0e2eec20..4da50d707 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -429,14 +429,7 @@ namespace Emby.Server.Implementations _validAddressResults.Clear(); } - private Version _applicationVersion; - /// - /// Gets the current application server version - /// - /// The application server version. - public Version ApplicationVersion => _applicationVersion ?? (_applicationVersion = typeof(ApplicationHost).Assembly.GetName().Version); - - public string ApplicationSemanticVersion => ApplicationVersion.ToString(3); + public string ApplicationSemanticVersion => typeof(ApplicationHost).Assembly.GetName().Version.ToString(3); /// /// Gets the current application server version diff --git a/MediaBrowser.Api/PackageService.cs b/MediaBrowser.Api/PackageService.cs index c202f0f6b..16819ee37 100644 --- a/MediaBrowser.Api/PackageService.cs +++ b/MediaBrowser.Api/PackageService.cs @@ -139,7 +139,7 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetPackage request) { - var packages = _installationManager.GetAvailablePackages(CancellationToken.None, applicationVersion: _appHost.ApplicationVersion).Result; + var packages = _installationManager.GetAvailablePackages(CancellationToken.None, applicationVersion: typeof(PackageService).Assembly.GetName().Version).Result; var result = packages.FirstOrDefault(p => string.Equals(p.guid, request.AssemblyGuid ?? "none", StringComparison.OrdinalIgnoreCase)) ?? packages.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase)); @@ -154,7 +154,7 @@ namespace MediaBrowser.Api /// System.Object. public async Task Get(GetPackages request) { - IEnumerable packages = await _installationManager.GetAvailablePackages(CancellationToken.None, false, request.PackageType, _appHost.ApplicationVersion).ConfigureAwait(false); + IEnumerable packages = await _installationManager.GetAvailablePackages(CancellationToken.None, false, request.PackageType, typeof(PackageService).Assembly.GetName().Version).ConfigureAwait(false); if (!string.IsNullOrEmpty(request.TargetSystems)) { @@ -189,7 +189,7 @@ namespace MediaBrowser.Api public async Task Post(InstallPackage request) { var package = string.IsNullOrEmpty(request.Version) ? - await _installationManager.GetLatestCompatibleVersion(request.Name, request.AssemblyGuid, _appHost.ApplicationVersion, request.UpdateClass).ConfigureAwait(false) : + await _installationManager.GetLatestCompatibleVersion(request.Name, request.AssemblyGuid, typeof(PackageService).Assembly.GetName().Version, request.UpdateClass).ConfigureAwait(false) : await _installationManager.GetPackage(request.Name, request.AssemblyGuid, request.UpdateClass, Version.Parse(request.Version)).ConfigureAwait(false); if (package == null) diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs index 94dd251cf..06437c6a9 100644 --- a/MediaBrowser.Common/IApplicationHost.cs +++ b/MediaBrowser.Common/IApplicationHost.cs @@ -65,12 +65,6 @@ namespace MediaBrowser.Common /// void Restart(); - /// - /// Gets the application version. - /// - /// The application version. - Version ApplicationVersion { get; } - /// /// Gets the application semantic version. /// From 8de4eb7d197af0df2a81cbf0e6249c5ff83987b1 Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sat, 19 Jan 2019 21:35:33 -0500 Subject: [PATCH 2/5] Rename ApplicationSemanticVersion to ApplicationVersion --- Emby.Dlna/PlayTo/PlayToManager.cs | 2 +- Emby.Server.Implementations/ApplicationHost.cs | 8 ++++---- .../LiveTv/TunerHosts/M3uParser.cs | 2 +- MediaBrowser.Api/Session/SessionsService.cs | 2 +- MediaBrowser.Common/IApplicationHost.cs | 6 +++--- MediaBrowser.WebDashboard/Api/DashboardService.cs | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs index cdc8f7717..8e82e6f69 100644 --- a/Emby.Dlna/PlayTo/PlayToManager.cs +++ b/Emby.Dlna/PlayTo/PlayToManager.cs @@ -164,7 +164,7 @@ namespace Emby.Dlna.PlayTo string deviceName = null; - var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationSemanticVersion, uuid, deviceName, uri.OriginalString, null); + var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersion, uuid, deviceName, uri.OriginalString, null); var controller = sessionInfo.SessionControllers.OfType().FirstOrDefault(); diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 4da50d707..d0b5c1597 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -429,13 +429,13 @@ namespace Emby.Server.Implementations _validAddressResults.Clear(); } - public string ApplicationSemanticVersion => typeof(ApplicationHost).Assembly.GetName().Version.ToString(3); + public string ApplicationVersion => typeof(ApplicationHost).Assembly.GetName().Version.ToString(3); /// /// Gets the current application server version /// /// The application server version. - public string ApplicationUserAgent => Name.Replace(' ','-') + "/" + ApplicationSemanticVersion; + public string ApplicationUserAgent => Name.Replace(' ','-') + "/" + ApplicationVersion; private string _productName; /// @@ -1814,7 +1814,7 @@ namespace Emby.Server.Implementations { HasPendingRestart = HasPendingRestart, IsShuttingDown = IsShuttingDown, - Version = ApplicationSemanticVersion, + Version = ApplicationVersion, ProductName = ApplicationProductName, WebSocketPortNumber = HttpPort, CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(), @@ -1861,7 +1861,7 @@ namespace Emby.Server.Implementations var wanAddress = await GetWanApiUrl(cancellationToken).ConfigureAwait(false); return new PublicSystemInfo { - Version = ApplicationSemanticVersion, + Version = ApplicationVersion, Id = SystemId, OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(), WanAddress = wanAddress, diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index f93e7f78e..4fe031f42 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts Url = url, CancellationToken = cancellationToken, // Some data providers will require a user agent - UserAgent = _appHost.ApplicationSemanticVersion + UserAgent = _appHost.ApplicationVersion }); } return Task.FromResult(_fileSystem.OpenRead(url)); diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index cba278c1e..c9a11c117 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -309,7 +309,7 @@ namespace MediaBrowser.Api.Session DateCreated = DateTime.UtcNow, DeviceId = _appHost.SystemId, DeviceName = _appHost.FriendlyName, - AppVersion = _appHost.ApplicationSemanticVersion + AppVersion = _appHost.ApplicationVersion }); } diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs index 06437c6a9..385127c54 100644 --- a/MediaBrowser.Common/IApplicationHost.cs +++ b/MediaBrowser.Common/IApplicationHost.cs @@ -66,10 +66,10 @@ namespace MediaBrowser.Common void Restart(); /// - /// Gets the application semantic version. + /// Gets the application version. /// - /// The application semantic version. - string ApplicationSemanticVersion { get; } + /// The application version. + string ApplicationVersion { get; } /// /// Gets the application user agent. diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index c31f3a97e..db0011114 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -205,7 +205,7 @@ namespace MediaBrowser.WebDashboard.Api return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => Task.FromResult(stream)); } - return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator(DashboardUIPath).ModifyHtml("dummy.html", stream, null, _appHost.ApplicationSemanticVersion, null)); + return _resultFactory.GetStaticResult(Request, plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator(DashboardUIPath).ModifyHtml("dummy.html", stream, null, _appHost.ApplicationVersion, null)); } throw new ResourceNotFoundException(); @@ -342,7 +342,7 @@ namespace MediaBrowser.WebDashboard.Api cacheDuration = TimeSpan.FromDays(365); } - var cacheKey = (_appHost.ApplicationSemanticVersion + (localizationCulture ?? string.Empty) + path).GetMD5(); + var cacheKey = (_appHost.ApplicationVersion + (localizationCulture ?? string.Empty) + path).GetMD5(); // html gets modified on the fly if (contentType.StartsWith("text/html", StringComparison.OrdinalIgnoreCase)) @@ -364,7 +364,7 @@ namespace MediaBrowser.WebDashboard.Api private Task GetResourceStream(string basePath, string virtualPath, string localizationCulture) { return GetPackageCreator(basePath) - .GetResource(virtualPath, null, localizationCulture, _appHost.ApplicationSemanticVersion); + .GetResource(virtualPath, null, localizationCulture, _appHost.ApplicationVersion); } private PackageCreator GetPackageCreator(string basePath) @@ -400,7 +400,7 @@ namespace MediaBrowser.WebDashboard.Api CopyDirectory(inputPath, targetPath); } - var appVersion = _appHost.ApplicationSemanticVersion; + var appVersion = _appHost.ApplicationVersion; await DumpHtml(packageCreator, inputPath, targetPath, mode, appVersion); From d7da475aada74a4b89acc81f5b033442ae12d0cd Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sat, 19 Jan 2019 21:38:42 -0500 Subject: [PATCH 3/5] Fix User-Agent --- Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 4fe031f42..a54a53b25 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts Url = url, CancellationToken = cancellationToken, // Some data providers will require a user agent - UserAgent = _appHost.ApplicationVersion + UserAgent = _appHost.ApplicationUserAgent }); } return Task.FromResult(_fileSystem.OpenRead(url)); From 235125df5751cc95782a0a3913ee71c9aba8c896 Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sat, 19 Jan 2019 21:41:48 -0500 Subject: [PATCH 4/5] Fix ApplicationUserAgent documentation --- Emby.Server.Implementations/ApplicationHost.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index d0b5c1597..97df87377 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -432,9 +432,9 @@ namespace Emby.Server.Implementations public string ApplicationVersion => typeof(ApplicationHost).Assembly.GetName().Version.ToString(3); /// - /// Gets the current application server version + /// Gets the current application user agent /// - /// The application server version. + /// The application user agent. public string ApplicationUserAgent => Name.Replace(' ','-') + "/" + ApplicationVersion; private string _productName; From f229c641a14d45485aac63aabd09f16c5aec28ce Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Sat, 19 Jan 2019 21:48:38 -0500 Subject: [PATCH 5/5] Remove redundant GetDefaultUserAgent --- Emby.Server.Implementations/ApplicationHost.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 97df87377..b4b90ac86 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -752,7 +752,7 @@ namespace Emby.Server.Implementations protected virtual IHttpClient CreateHttpClient() { - return new HttpClientManager.HttpClientManager(ApplicationPaths, LoggerFactory.CreateLogger("HttpClient"), FileSystemManager, GetDefaultUserAgent); + return new HttpClientManager.HttpClientManager(ApplicationPaths, LoggerFactory.CreateLogger("HttpClient"), FileSystemManager, () => ApplicationUserAgent); } public static IStreamHelper StreamHelper { get; set; } @@ -1010,11 +1010,6 @@ namespace Emby.Server.Implementations } } - protected string GetDefaultUserAgent() - { - return ApplicationUserAgent; - } - protected virtual bool SupportsDualModeSockets => true; private X509Certificate GetCertificate(CertificateInfo info)