Merge pull request #627 from nvllsvm/version

Use string for ApplicationVersion
This commit is contained in:
Andrew Rabert 2019-01-19 22:39:20 -05:00 committed by GitHub
commit d72d0fb865
7 changed files with 18 additions and 36 deletions

View file

@ -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<PlayToController>().FirstOrDefault();

View file

@ -429,20 +429,13 @@ namespace Emby.Server.Implementations
_validAddressResults.Clear();
}
private Version _applicationVersion;
/// <summary>
/// Gets the current application server version
/// </summary>
/// <value>The application server version.</value>
public Version ApplicationVersion => _applicationVersion ?? (_applicationVersion = typeof(ApplicationHost).Assembly.GetName().Version);
public string ApplicationSemanticVersion => ApplicationVersion.ToString(3);
public string ApplicationVersion => typeof(ApplicationHost).Assembly.GetName().Version.ToString(3);
/// <summary>
/// Gets the current application server version
/// Gets the current application user agent
/// </summary>
/// <value>The application server version.</value>
public string ApplicationUserAgent => Name.Replace(' ','-') + "/" + ApplicationSemanticVersion;
/// <value>The application user agent.</value>
public string ApplicationUserAgent => Name.Replace(' ','-') + "/" + ApplicationVersion;
private string _productName;
/// <summary>
@ -759,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; }
@ -1017,11 +1010,6 @@ namespace Emby.Server.Implementations
}
}
protected string GetDefaultUserAgent()
{
return ApplicationUserAgent;
}
protected virtual bool SupportsDualModeSockets => true;
private X509Certificate GetCertificate(CertificateInfo info)
@ -1821,7 +1809,7 @@ namespace Emby.Server.Implementations
{
HasPendingRestart = HasPendingRestart,
IsShuttingDown = IsShuttingDown,
Version = ApplicationSemanticVersion,
Version = ApplicationVersion,
ProductName = ApplicationProductName,
WebSocketPortNumber = HttpPort,
CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
@ -1868,7 +1856,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,

View file

@ -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.ApplicationUserAgent
});
}
return Task.FromResult(_fileSystem.OpenRead(url));

View file

@ -139,7 +139,7 @@ namespace MediaBrowser.Api
/// <returns>System.Object.</returns>
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
/// <returns>System.Object.</returns>
public async Task<object> Get(GetPackages request)
{
IEnumerable<PackageInfo> packages = await _installationManager.GetAvailablePackages(CancellationToken.None, false, request.PackageType, _appHost.ApplicationVersion).ConfigureAwait(false);
IEnumerable<PackageInfo> 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)

View file

@ -309,7 +309,7 @@ namespace MediaBrowser.Api.Session
DateCreated = DateTime.UtcNow,
DeviceId = _appHost.SystemId,
DeviceName = _appHost.FriendlyName,
AppVersion = _appHost.ApplicationSemanticVersion
AppVersion = _appHost.ApplicationVersion
});
}

View file

@ -69,13 +69,7 @@ namespace MediaBrowser.Common
/// Gets the application version.
/// </summary>
/// <value>The application version.</value>
Version ApplicationVersion { get; }
/// <summary>
/// Gets the application semantic version.
/// </summary>
/// <value>The application semantic version.</value>
string ApplicationSemanticVersion { get; }
string ApplicationVersion { get; }
/// <summary>
/// Gets the application user agent.

View file

@ -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<Stream> 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);