diff --git a/src/NzbDrone.Common.Test/PathExtensionFixture.cs b/src/NzbDrone.Common.Test/PathExtensionFixture.cs index e18a3d7b2..bad251fc4 100644 --- a/src/NzbDrone.Common.Test/PathExtensionFixture.cs +++ b/src/NzbDrone.Common.Test/PathExtensionFixture.cs @@ -278,7 +278,7 @@ namespace NzbDrone.Common.Test [Test] public void GetUpdateClientExePath() { - GetIAppDirectoryInfo().GetUpdateClientExePath(PlatformType.DotNet).Should().BeEquivalentTo(@"C:\Temp\radarr_update\Radarr.Update.exe".AsOsAgnostic()); + GetIAppDirectoryInfo().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\radarr_update\Radarr.Update".AsOsAgnostic().ProcessNameToExe()); } [Test] diff --git a/src/NzbDrone.Common/EnvironmentInfo/PlatformInfo.cs b/src/NzbDrone.Common/EnvironmentInfo/PlatformInfo.cs index 76f323652..68a0ca092 100644 --- a/src/NzbDrone.Common/EnvironmentInfo/PlatformInfo.cs +++ b/src/NzbDrone.Common/EnvironmentInfo/PlatformInfo.cs @@ -2,13 +2,6 @@ using System; namespace NzbDrone.Common.EnvironmentInfo { - public enum PlatformType - { - DotNet = 0, - Mono = 1, - NetCore = 2 - } - public interface IPlatformInfo { Version Version { get; } @@ -16,31 +9,18 @@ namespace NzbDrone.Common.EnvironmentInfo public class PlatformInfo : IPlatformInfo { - private static PlatformType _platform; private static Version _version; static PlatformInfo() { - _platform = PlatformType.NetCore; _version = Environment.Version; } - public static PlatformType Platform => _platform; - public static bool IsDotNet => Platform == PlatformType.DotNet; - public static bool IsNetCore => Platform == PlatformType.NetCore; - public static string PlatformName { get { - if (IsDotNet) - { - return ".NET"; - } - else - { - return ".NET Core"; - } + return ".NET"; } } diff --git a/src/NzbDrone.Common/Extensions/PathExtensions.cs b/src/NzbDrone.Common/Extensions/PathExtensions.cs index 31ec962b7..9975e9446 100644 --- a/src/NzbDrone.Common/Extensions/PathExtensions.cs +++ b/src/NzbDrone.Common/Extensions/PathExtensions.cs @@ -267,9 +267,9 @@ namespace NzbDrone.Common.Extensions return substring.Substring(0, lastSeparatorIndex); } - public static string ProcessNameToExe(this string processName, PlatformType runtime) + public static string ProcessNameToExe(this string processName) { - if (OsInfo.IsWindows || runtime != PlatformType.NetCore) + if (OsInfo.IsWindows) { processName += ".exe"; } @@ -277,11 +277,6 @@ namespace NzbDrone.Common.Extensions return processName; } - public static string ProcessNameToExe(this string processName) - { - return processName.ProcessNameToExe(PlatformInfo.Platform); - } - public static string GetAppDataPath(this IAppFolderInfo appFolderInfo) { return appFolderInfo.AppDataFolder; @@ -352,9 +347,9 @@ namespace NzbDrone.Common.Extensions return Path.Combine(GetUpdatePackageFolder(appFolderInfo), UPDATE_CLIENT_FOLDER_NAME); } - public static string GetUpdateClientExePath(this IAppFolderInfo appFolderInfo, PlatformType runtime) + public static string GetUpdateClientExePath(this IAppFolderInfo appFolderInfo) { - return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_CLIENT_EXE_NAME).ProcessNameToExe(runtime); + return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_CLIENT_EXE_NAME).ProcessNameToExe(); } public static string GetDatabase(this IAppFolderInfo appFolderInfo) diff --git a/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs b/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs index 969bd9f95..cf7b0e8f5 100644 --- a/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs +++ b/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs @@ -69,7 +69,7 @@ namespace NzbDrone.Core.Test.UpdateTests .Returns(true); Mocker.GetMock() - .Setup(v => v.FileExists(It.Is(s => s.EndsWith("Radarr.Update.exe")))) + .Setup(v => v.FileExists(It.Is(s => s.EndsWith("Radarr.Update".ProcessNameToExe())))) .Returns(true); _sandboxFolder = Mocker.GetMock().Object.GetUpdateSandboxFolder(); @@ -165,7 +165,7 @@ namespace NzbDrone.Core.Test.UpdateTests public void should_return_with_warning_if_updater_doesnt_exists() { Mocker.GetMock() - .Setup(v => v.FileExists(It.Is(s => s.EndsWith("Radarr.Update.exe")))) + .Setup(v => v.FileExists(It.Is(s => s.EndsWith("Radarr.Update".ProcessNameToExe())))) .Returns(false); Subject.Execute(new ApplicationUpdateCommand()); diff --git a/src/NzbDrone.Core/HealthCheck/ServerSideNotificationService.cs b/src/NzbDrone.Core/HealthCheck/ServerSideNotificationService.cs index 7401f5b90..2d0c1f8f9 100644 --- a/src/NzbDrone.Core/HealthCheck/ServerSideNotificationService.cs +++ b/src/NzbDrone.Core/HealthCheck/ServerSideNotificationService.cs @@ -52,7 +52,7 @@ namespace NzbDrone.Core.HealthCheck .AddQueryParam("version", BuildInfo.Version) .AddQueryParam("os", OsInfo.Os.ToString().ToLowerInvariant()) .AddQueryParam("arch", RuntimeInformation.OSArchitecture) - .AddQueryParam("runtime", PlatformInfo.Platform.ToString().ToLowerInvariant()) + .AddQueryParam("runtime", "netcore") .AddQueryParam("branch", _configFileProvider.Branch) .Build(); try diff --git a/src/NzbDrone.Core/Update/InstallUpdateService.cs b/src/NzbDrone.Core/Update/InstallUpdateService.cs index 5717f4d94..06c364894 100644 --- a/src/NzbDrone.Core/Update/InstallUpdateService.cs +++ b/src/NzbDrone.Core/Update/InstallUpdateService.cs @@ -146,7 +146,7 @@ namespace NzbDrone.Core.Update _logger.Info("Preparing client"); _diskTransferService.TransferFolder(_appFolderInfo.GetUpdateClientFolder(), updateSandboxFolder, TransferMode.Move); - var updateClientExePath = _appFolderInfo.GetUpdateClientExePath(updatePackage.Runtime); + var updateClientExePath = _appFolderInfo.GetUpdateClientExePath(); if (!_diskProvider.FileExists(updateClientExePath)) { @@ -155,7 +155,7 @@ namespace NzbDrone.Core.Update } // Set executable flag on update app - if (OsInfo.IsOsx || (OsInfo.IsLinux && PlatformInfo.IsNetCore)) + if (OsInfo.IsOsx || OsInfo.IsLinux) { _diskProvider.SetFilePermissions(updateClientExePath, "755", null); } diff --git a/src/NzbDrone.Core/Update/UpdatePackage.cs b/src/NzbDrone.Core/Update/UpdatePackage.cs index 016398d0f..ca97ad5d0 100644 --- a/src/NzbDrone.Core/Update/UpdatePackage.cs +++ b/src/NzbDrone.Core/Update/UpdatePackage.cs @@ -1,4 +1,4 @@ -using System; +using System; using NzbDrone.Common.EnvironmentInfo; namespace NzbDrone.Core.Update @@ -12,6 +12,5 @@ namespace NzbDrone.Core.Update public UpdateChanges Changes { get; set; } public string Hash { get; set; } public string Branch { get; set; } - public PlatformType Runtime { get; set; } } } diff --git a/src/NzbDrone.Core/Update/UpdatePackageProvider.cs b/src/NzbDrone.Core/Update/UpdatePackageProvider.cs index 40f91fbfb..50c09f755 100644 --- a/src/NzbDrone.Core/Update/UpdatePackageProvider.cs +++ b/src/NzbDrone.Core/Update/UpdatePackageProvider.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; +using FluentValidation.Validators; using NzbDrone.Common.Cloud; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Http; @@ -39,7 +40,7 @@ namespace NzbDrone.Core.Update .AddQueryParam("version", currentVersion) .AddQueryParam("os", OsInfo.Os.ToString().ToLowerInvariant()) .AddQueryParam("arch", RuntimeInformation.OSArchitecture) - .AddQueryParam("runtime", PlatformInfo.Platform.ToString().ToLowerInvariant()) + .AddQueryParam("runtime", "netcore") .AddQueryParam("runtimeVer", _platformInfo.Version) .AddQueryParam("dbType", _mainDatabase.DatabaseType) .SetSegment("branch", branch); @@ -67,7 +68,7 @@ namespace NzbDrone.Core.Update .AddQueryParam("version", currentVersion) .AddQueryParam("os", OsInfo.Os.ToString().ToLowerInvariant()) .AddQueryParam("arch", RuntimeInformation.OSArchitecture) - .AddQueryParam("runtime", PlatformInfo.Platform.ToString().ToLowerInvariant()) + .AddQueryParam("runtime", "netcore") .AddQueryParam("runtimeVer", _platformInfo.Version) .SetSegment("branch", branch); diff --git a/src/NzbDrone.Mono/Disk/DiskProvider.cs b/src/NzbDrone.Mono/Disk/DiskProvider.cs index e18332124..0ddee8441 100644 --- a/src/NzbDrone.Mono/Disk/DiskProvider.cs +++ b/src/NzbDrone.Mono/Disk/DiskProvider.cs @@ -247,9 +247,7 @@ namespace NzbDrone.Mono.Disk newFile.CreateSymbolicLinkTo(fullPath); } } - else if (((PlatformInfo.Platform == PlatformType.Mono && PlatformInfo.GetVersion() >= new Version(6, 0)) || - PlatformInfo.Platform == PlatformType.NetCore) && - (!FileExists(destination) || overwrite)) + else if (!FileExists(destination) || overwrite) { TransferFilePatched(source, destination, overwrite, false); } @@ -294,14 +292,9 @@ namespace NzbDrone.Mono.Disk throw; } } - else if ((PlatformInfo.Platform == PlatformType.Mono && PlatformInfo.GetVersion() >= new Version(6, 0)) || - PlatformInfo.Platform == PlatformType.NetCore) - { - TransferFilePatched(source, destination, false, true); - } else { - base.MoveFileInternal(source, destination); + TransferFilePatched(source, destination, false, true); } } @@ -313,7 +306,7 @@ namespace NzbDrone.Mono.Disk // Catch the exception and attempt to handle these edgecases // Mono 6.x till 6.10 doesn't properly try use rename first. - if (move && (PlatformInfo.Platform == PlatformType.NetCore)) + if (move) { if (Syscall.lstat(source, out var sourcestat) == 0 && Syscall.lstat(destination, out var deststat) != 0 && @@ -341,7 +334,7 @@ namespace NzbDrone.Mono.Disk var dstInfo = new FileInfo(destination); var exists = dstInfo.Exists && srcInfo.Exists; - if (PlatformInfo.Platform == PlatformType.NetCore && exists && dstInfo.Length == srcInfo.Length) + if (exists && dstInfo.Length == srcInfo.Length) { // mono 6.0, mono 6.4 and netcore 3.1 bug: full length file since utime and chmod happens at the end _logger.Debug("{3} failed to {2} file likely due to known {3} bug, attempting to {2} directly. '{0}' -> '{1}'", source, destination, move ? "move" : "copy", PlatformInfo.PlatformName); diff --git a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs index 1a1abd2ed..1e67e653f 100644 --- a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs +++ b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs @@ -129,7 +129,7 @@ namespace NzbDrone.Update.UpdateEngine _diskTransferService.MirrorFolder(_appFolderInfo.GetUpdatePackageFolder(), installationFolder); // Set executable flag on app and ffprobe - if (OsInfo.IsOsx || (OsInfo.IsLinux && PlatformInfo.IsNetCore)) + if (OsInfo.IsOsx || OsInfo.IsLinux) { _diskProvider.SetFilePermissions(Path.Combine(installationFolder, "Radarr"), "755", null); _diskProvider.SetFilePermissions(Path.Combine(installationFolder, "ffprobe"), "755", null); diff --git a/src/Radarr.Api.V3/System/SystemController.cs b/src/Radarr.Api.V3/System/SystemController.cs index c759f7b9e..cd009a713 100644 --- a/src/Radarr.Api.V3/System/SystemController.cs +++ b/src/Radarr.Api.V3/System/SystemController.cs @@ -70,7 +70,7 @@ namespace Radarr.Api.V3.System AppData = _appFolderInfo.GetAppDataPath(), OsName = _osInfo.Name, OsVersion = _osInfo.Version, - IsNetCore = PlatformInfo.IsNetCore, + IsNetCore = true, IsLinux = OsInfo.IsLinux, IsOsx = OsInfo.IsOsx, IsWindows = OsInfo.IsWindows, @@ -83,7 +83,7 @@ namespace Radarr.Api.V3.System MigrationVersion = _database.Migration, UrlBase = _configFileProvider.UrlBase, RuntimeVersion = _platformInfo.Version, - RuntimeName = PlatformInfo.Platform, + RuntimeName = "netcore", StartTime = _runtimeInfo.StartTime, PackageVersion = _deploymentInfoProvider.PackageVersion, PackageAuthor = _deploymentInfoProvider.PackageAuthor,