mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
Cleaned up environment detection
This commit is contained in:
parent
cf77104a02
commit
f4c202441c
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using NLog;
|
using NLog;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
@ -11,7 +12,7 @@ namespace NzbDrone.Api.Frontend.Mappers
|
|||||||
{
|
{
|
||||||
private readonly IDiskProvider _diskProvider;
|
private readonly IDiskProvider _diskProvider;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
private readonly bool _caseSensitive;
|
private readonly StringComparison _caseSensitive;
|
||||||
|
|
||||||
private static readonly NotFoundResponse NotFoundResponse = new NotFoundResponse();
|
private static readonly NotFoundResponse NotFoundResponse = new NotFoundResponse();
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ namespace NzbDrone.Api.Frontend.Mappers
|
|||||||
|
|
||||||
if (!RuntimeInfoBase.IsProduction)
|
if (!RuntimeInfoBase.IsProduction)
|
||||||
{
|
{
|
||||||
_caseSensitive = true;
|
_caseSensitive = StringComparison.OrdinalIgnoreCase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,16 +51,16 @@ namespace NzbDrone.Api.System
|
|||||||
StartupPath = _appFolderInfo.StartUpFolder,
|
StartupPath = _appFolderInfo.StartUpFolder,
|
||||||
AppData = _appFolderInfo.GetAppDataPath(),
|
AppData = _appFolderInfo.GetAppDataPath(),
|
||||||
OsVersion = OsInfo.Version.ToString(),
|
OsVersion = OsInfo.Version.ToString(),
|
||||||
IsMonoRuntime = OsInfo.IsMono,
|
IsMonoRuntime = OsInfo.IsMonoRuntime,
|
||||||
IsMono = OsInfo.IsMono,
|
IsMono = OsInfo.IsNotWindows,
|
||||||
IsLinux = OsInfo.IsMono,
|
IsLinux = OsInfo.IsLinux,
|
||||||
IsOsx = OsInfo.IsOsx,
|
IsOsx = OsInfo.IsOsx,
|
||||||
IsWindows = OsInfo.IsWindows,
|
IsWindows = OsInfo.IsWindows,
|
||||||
Branch = _configFileProvider.Branch,
|
Branch = _configFileProvider.Branch,
|
||||||
Authentication = _configFileProvider.AuthenticationEnabled,
|
Authentication = _configFileProvider.AuthenticationEnabled,
|
||||||
SqliteVersion = _database.Version,
|
SqliteVersion = _database.Version,
|
||||||
UrlBase = _configFileProvider.UrlBase,
|
UrlBase = _configFileProvider.UrlBase,
|
||||||
RuntimeVersion = OsInfo.IsMono ? _runtimeInfo.RuntimeVersion : null
|
RuntimeVersion = _runtimeInfo.RuntimeVersion
|
||||||
}.AsResponse();
|
}.AsResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,4 +82,3 @@ namespace NzbDrone.Api.System
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -87,19 +87,26 @@ namespace NzbDrone.Common.Disk
|
|||||||
public bool FileExists(string path)
|
public bool FileExists(string path)
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath();
|
Ensure.That(path, () => path).IsValidPath();
|
||||||
return FileExists(path, OsInfo.IsMono);
|
return FileExists(path, OsInfo.PathStringComparison);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool FileExists(string path, bool caseSensitive)
|
public bool FileExists(string path, StringComparison stringComparison)
|
||||||
{
|
{
|
||||||
Ensure.That(path, () => path).IsValidPath();
|
Ensure.That(path, () => path).IsValidPath();
|
||||||
|
|
||||||
if (caseSensitive)
|
switch (stringComparison)
|
||||||
{
|
{
|
||||||
return File.Exists(path) && path == path.GetActualCasing();
|
case StringComparison.CurrentCulture:
|
||||||
|
case StringComparison.InvariantCulture:
|
||||||
|
case StringComparison.Ordinal:
|
||||||
|
{
|
||||||
|
return File.Exists(path) && path == path.GetActualCasing();
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return File.Exists(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return File.Exists(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] GetDirectories(string path)
|
public string[] GetDirectories(string path)
|
||||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Common.Disk
|
|||||||
void EnsureFolder(string path);
|
void EnsureFolder(string path);
|
||||||
bool FolderExists(string path);
|
bool FolderExists(string path);
|
||||||
bool FileExists(string path);
|
bool FileExists(string path);
|
||||||
bool FileExists(string path, bool caseSensitive);
|
bool FileExists(string path, StringComparison stringComparison);
|
||||||
string[] GetDirectories(string path);
|
string[] GetDirectories(string path);
|
||||||
string[] GetFiles(string path, SearchOption searchOption);
|
string[] GetFiles(string path, SearchOption searchOption);
|
||||||
long GetFolderSize(string path);
|
long GetFolderSize(string path);
|
||||||
|
@ -101,7 +101,7 @@ namespace NzbDrone.Common.EnsureThat
|
|||||||
|
|
||||||
if (param.Value.IsPathValid()) return param;
|
if (param.Value.IsPathValid()) return param;
|
||||||
|
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
throw ExceptionFactory.CreateForParamValidation(param.Name, string.Format("value [{0}] is not a valid *nix path. paths must start with /", param.Value));
|
throw ExceptionFactory.CreateForParamValidation(param.Name, string.Format("value [{0}] is not a valid *nix path. paths must start with /", param.Value));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||||||
{
|
{
|
||||||
_diskProvider.EnsureFolder(_appFolderInfo.AppDataFolder);
|
_diskProvider.EnsureFolder(_appFolderInfo.AppDataFolder);
|
||||||
|
|
||||||
if (!OsInfo.IsMono)
|
if (OsInfo.IsWindows)
|
||||||
{
|
{
|
||||||
SetPermissions();
|
SetPermissions();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||||||
|
|
||||||
public AppFolderInfo(IStartupContext startupContext)
|
public AppFolderInfo(IStartupContext startupContext)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
DATA_SPECIAL_FOLDER = Environment.SpecialFolder.ApplicationData;
|
DATA_SPECIAL_FOLDER = Environment.SpecialFolder.ApplicationData;
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,16 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||||||
Version = Environment.OSVersion.Version;
|
Version = Environment.OSVersion.Version;
|
||||||
|
|
||||||
IsMonoRuntime = Type.GetType("Mono.Runtime") != null;
|
IsMonoRuntime = Type.GetType("Mono.Runtime") != null;
|
||||||
IsMono = (platform == 4) || (platform == 6) || (platform == 128);
|
IsNotWindows = (platform == 4) || (platform == 6) || (platform == 128);
|
||||||
IsOsx = IsRunningOnMac();
|
IsOsx = IsRunningOnMac();
|
||||||
IsLinux = IsMono && !IsOsx;
|
IsLinux = IsNotWindows && !IsOsx;
|
||||||
IsWindows = !IsMono;
|
IsWindows = !IsNotWindows;
|
||||||
|
|
||||||
FirstDayOfWeek = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
|
FirstDayOfWeek = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
|
||||||
|
|
||||||
if (!IsMono)
|
if (IsWindows)
|
||||||
{
|
{
|
||||||
Os = Os.Windows;
|
Os = Os.Windows;
|
||||||
|
|
||||||
PathStringComparison = StringComparison.OrdinalIgnoreCase;
|
PathStringComparison = StringComparison.OrdinalIgnoreCase;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -38,7 +37,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||||||
|
|
||||||
public static Version Version { get; private set; }
|
public static Version Version { get; private set; }
|
||||||
public static bool IsMonoRuntime { get; private set; }
|
public static bool IsMonoRuntime { get; private set; }
|
||||||
public static bool IsMono { get; private set; }
|
public static bool IsNotWindows { get; private set; }
|
||||||
public static bool IsLinux { get; private set; }
|
public static bool IsLinux { get; private set; }
|
||||||
public static bool IsOsx { get; private set; }
|
public static bool IsOsx { get; private set; }
|
||||||
public static bool IsWindows { get; private set; }
|
public static bool IsWindows { get; private set; }
|
||||||
|
@ -9,7 +9,7 @@ namespace NzbDrone.Common.Exceptron
|
|||||||
|
|
||||||
public static Exception ExceptronIgnoreOnMono(this Exception exception)
|
public static Exception ExceptronIgnoreOnMono(this Exception exception)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
exception.ExceptronIgnore();
|
exception.ExceptronIgnore();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace NzbDrone.Common.Extensions
|
|||||||
|
|
||||||
var info = new FileInfo(path.Trim());
|
var info = new FileInfo(path.Trim());
|
||||||
|
|
||||||
if (!OsInfo.IsMono && info.FullName.StartsWith(@"\\")) //UNC
|
if (OsInfo.IsWindows && info.FullName.StartsWith(@"\\")) //UNC
|
||||||
{
|
{
|
||||||
return info.FullName.TrimEnd('/', '\\', ' ');
|
return info.FullName.TrimEnd('/', '\\', ' ');
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ namespace NzbDrone.Common.Extensions
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
return path.StartsWith(Path.DirectorySeparatorChar.ToString());
|
return path.StartsWith(Path.DirectorySeparatorChar.ToString());
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ namespace NzbDrone.Common.Extensions
|
|||||||
|
|
||||||
public static string GetActualCasing(this string path)
|
public static string GetActualCasing(this string path)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono || path.StartsWith("\\"))
|
if (OsInfo.IsNotWindows || path.StartsWith("\\"))
|
||||||
{
|
{
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,10 @@ namespace NzbDrone.Common.Http
|
|||||||
public class HttpClient : IHttpClient
|
public class HttpClient : IHttpClient
|
||||||
{
|
{
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
private readonly string _userAgent;
|
|
||||||
|
|
||||||
public HttpClient(Logger logger)
|
public HttpClient(Logger logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_userAgent = String.Format("Sonarr/{0} ({1} {2})",
|
|
||||||
BuildInfo.Version,
|
|
||||||
OsInfo.Os, OsInfo.Version.ToString(2));
|
|
||||||
ServicePointManager.DefaultConnectionLimit = 12;
|
ServicePointManager.DefaultConnectionLimit = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +40,7 @@ namespace NzbDrone.Common.Http
|
|||||||
|
|
||||||
webRequest.Credentials = request.NetworkCredential;
|
webRequest.Credentials = request.NetworkCredential;
|
||||||
webRequest.Method = request.Method.ToString();
|
webRequest.Method = request.Method.ToString();
|
||||||
webRequest.UserAgent = _userAgent;
|
webRequest.UserAgent = UserAgentBuilder.UserAgent;
|
||||||
webRequest.KeepAlive = false;
|
webRequest.KeepAlive = false;
|
||||||
webRequest.AllowAutoRedirect = request.AllowAutoRedirect;
|
webRequest.AllowAutoRedirect = request.AllowAutoRedirect;
|
||||||
|
|
||||||
@ -132,7 +128,7 @@ namespace NzbDrone.Common.Http
|
|||||||
|
|
||||||
var stopWatch = Stopwatch.StartNew();
|
var stopWatch = Stopwatch.StartNew();
|
||||||
var webClient = new GZipWebClient();
|
var webClient = new GZipWebClient();
|
||||||
webClient.Headers.Add(HttpRequestHeader.UserAgent, _userAgent);
|
webClient.Headers.Add(HttpRequestHeader.UserAgent, UserAgentBuilder.UserAgent);
|
||||||
webClient.DownloadFile(url, fileName);
|
webClient.DownloadFile(url, fileName);
|
||||||
stopWatch.Stop();
|
stopWatch.Stop();
|
||||||
_logger.Debug("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds);
|
_logger.Debug("Downloading Completed. took {0:0}s", stopWatch.Elapsed.Seconds);
|
||||||
|
17
src/NzbDrone.Common/Http/UserAgentBuilder.cs
Normal file
17
src/NzbDrone.Common/Http/UserAgentBuilder.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
|
||||||
|
namespace NzbDrone.Common.Http
|
||||||
|
{
|
||||||
|
public static class UserAgentBuilder
|
||||||
|
{
|
||||||
|
public static string UserAgent { get; private set; }
|
||||||
|
|
||||||
|
static UserAgentBuilder()
|
||||||
|
{
|
||||||
|
UserAgent = String.Format("Sonarr/{0} ({1} {2}) ",
|
||||||
|
BuildInfo.Version,
|
||||||
|
OsInfo.Os, OsInfo.Version.ToString(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,7 @@ namespace NzbDrone.Common.Instrumentation
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (inConsole && (OsInfo.IsMono || RuntimeInfoBase.IsUserInteractive))
|
if (inConsole && (OsInfo.IsNotWindows || RuntimeInfoBase.IsUserInteractive))
|
||||||
{
|
{
|
||||||
RegisterConsole();
|
RegisterConsole();
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,7 @@
|
|||||||
<Compile Include="Http\HttpRequestBuilder.cs" />
|
<Compile Include="Http\HttpRequestBuilder.cs" />
|
||||||
<Compile Include="Http\UriExtensions.cs" />
|
<Compile Include="Http\UriExtensions.cs" />
|
||||||
<Compile Include="Extensions\IEnumerableExtensions.cs" />
|
<Compile Include="Extensions\IEnumerableExtensions.cs" />
|
||||||
|
<Compile Include="Http\UserAgentBuilder.cs" />
|
||||||
<Compile Include="Instrumentation\CleanseLogMessage.cs" />
|
<Compile Include="Instrumentation\CleanseLogMessage.cs" />
|
||||||
<Compile Include="Instrumentation\ExceptronTarget.cs" />
|
<Compile Include="Instrumentation\ExceptronTarget.cs" />
|
||||||
<Compile Include="Instrumentation\Extensions\LoggerProgressExtensions.cs" />
|
<Compile Include="Instrumentation\Extensions\LoggerProgressExtensions.cs" />
|
||||||
|
@ -21,12 +21,12 @@ namespace NzbDrone.Common
|
|||||||
|
|
||||||
public int GetHashCode(string obj)
|
public int GetHashCode(string obj)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsWindows)
|
||||||
{
|
{
|
||||||
return obj.CleanFilePath().GetHashCode();
|
return obj.CleanFilePath().ToLower().GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj.CleanFilePath().ToLower().GetHashCode();
|
return obj.CleanFilePath().GetHashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,19 +25,20 @@ namespace NzbDrone.Common.Processes
|
|||||||
|
|
||||||
public void Write()
|
public void Write()
|
||||||
{
|
{
|
||||||
var filename = Path.Combine(_appFolderInfo.AppDataFolder, "nzbdrone.pid");
|
if (OsInfo.IsWindows)
|
||||||
|
|
||||||
if (OsInfo.IsMono)
|
|
||||||
{
|
{
|
||||||
try
|
return;
|
||||||
{
|
}
|
||||||
File.WriteAllText(filename, _processProvider.GetCurrentProcess().Id.ToString());
|
|
||||||
}
|
var filename = Path.Combine(_appFolderInfo.AppDataFolder, "nzbdrone.pid");
|
||||||
catch (Exception ex)
|
try
|
||||||
{
|
{
|
||||||
_logger.Error("Unable to write PID file: " + filename, ex);
|
File.WriteAllText(filename, _processProvider.GetCurrentProcess().Id.ToString());
|
||||||
throw;
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error("Unable to write PID file: " + filename, ex);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ namespace NzbDrone.Common.Processes
|
|||||||
|
|
||||||
public Process Start(string path, string args = null, Action<string> onOutputDataReceived = null, Action<string> onErrorDataReceived = null)
|
public Process Start(string path, string args = null, Action<string> onOutputDataReceived = null, Action<string> onErrorDataReceived = null)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase))
|
if (OsInfo.IsMonoRuntime && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
args = path + " " + args;
|
args = path + " " + args;
|
||||||
path = "mono";
|
path = "mono";
|
||||||
@ -155,7 +155,7 @@ namespace NzbDrone.Common.Processes
|
|||||||
|
|
||||||
public Process SpawnNewProcess(string path, string args = null)
|
public Process SpawnNewProcess(string path, string args = null)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase))
|
if (OsInfo.IsMonoRuntime && path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
args = path + " " + args;
|
args = path + " " + args;
|
||||||
path = "mono";
|
path = "mono";
|
||||||
|
@ -73,7 +73,7 @@ namespace NzbDrone.Core.Test.UpdateTests
|
|||||||
.Returns(path);
|
.Returns(path);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(s => s.FileExists(path, true))
|
.Setup(s => s.FileExists(path, StringComparison.Ordinal))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ namespace NzbDrone.Core.Test.UpdateTests
|
|||||||
GivenInstallScript(scriptPath);
|
GivenInstallScript(scriptPath);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(s => s.FileExists(scriptPath, true))
|
.Setup(s => s.FileExists(scriptPath, StringComparison.Ordinal))
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
|
|
||||||
Subject.Execute(new ApplicationUpdateCommand());
|
Subject.Execute(new ApplicationUpdateCommand());
|
||||||
|
@ -21,7 +21,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|||||||
|
|
||||||
public override HealthCheck Check()
|
public override HealthCheck Check()
|
||||||
{
|
{
|
||||||
if (!OsInfo.IsMono)
|
if (OsInfo.IsWindows)
|
||||||
{
|
{
|
||||||
return new HealthCheck(GetType());
|
return new HealthCheck(GetType());
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,10 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
|||||||
_checkUpdateService = checkUpdateService;
|
_checkUpdateService = checkUpdateService;
|
||||||
_configFileProvider = configFileProvider;
|
_configFileProvider = configFileProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override HealthCheck Check()
|
public override HealthCheck Check()
|
||||||
{
|
{
|
||||||
if (OsInfo.IsWindows || (OsInfo.IsMono && _configFileProvider.UpdateAutomatically))
|
if (OsInfo.IsWindows || _configFileProvider.UpdateAutomatically)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
|||||||
{
|
{
|
||||||
if (parent.Name.StartsWith(workingFolder))
|
if (parent.Name.StartsWith(workingFolder))
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
_logger.Debug("{0} is still being unpacked", localEpisode.Path);
|
_logger.Debug("{0} is still being unpacked", localEpisode.Path);
|
||||||
return false;
|
return false;
|
||||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||||||
|
|
||||||
public void SetFolderPermissions(string path)
|
public void SetFolderPermissions(string path)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
SetMonoPermissions(path, _configService.FolderChmod);
|
SetMonoPermissions(path, _configService.FolderChmod);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ namespace NzbDrone.Core.Update
|
|||||||
|
|
||||||
_backupService.Backup(BackupType.Update);
|
_backupService.Backup(BackupType.Update);
|
||||||
|
|
||||||
if (OsInfo.IsMono && _configFileProvider.UpdateMechanism == UpdateMechanism.Script)
|
if (OsInfo.IsNotWindows && _configFileProvider.UpdateMechanism == UpdateMechanism.Script)
|
||||||
{
|
{
|
||||||
InstallUpdateWithScript(updateSandboxFolder);
|
InstallUpdateWithScript(updateSandboxFolder);
|
||||||
return;
|
return;
|
||||||
@ -124,7 +124,7 @@ namespace NzbDrone.Core.Update
|
|||||||
throw new ArgumentException("Update Script has not been defined");
|
throw new ArgumentException("Update Script has not been defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_diskProvider.FileExists(scriptPath, true))
|
if (!_diskProvider.FileExists(scriptPath, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
var message = String.Format("Update Script: '{0}' does not exist", scriptPath);
|
var message = String.Format("Update Script: '{0}' does not exist", scriptPath);
|
||||||
throw new FileNotFoundException(message, scriptPath);
|
throw new FileNotFoundException(message, scriptPath);
|
||||||
|
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Update
|
|||||||
|
|
||||||
public UpdatePackage AvailableUpdate()
|
public UpdatePackage AvailableUpdate()
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono && !_configFileProvider.UpdateAutomatically)
|
if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ namespace NzbDrone.Host.AccessControl
|
|||||||
|
|
||||||
private bool IsFirewallEnabled()
|
private bool IsFirewallEnabled()
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono) return false;
|
if (OsInfo.IsNotWindows) return false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ namespace NzbDrone.Host
|
|||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
Console.CancelKeyPress += (sender, eventArgs) => LogManager.Configuration = null;
|
Console.CancelKeyPress += (sender, eventArgs) => LogManager.Configuration = null;
|
||||||
}
|
}
|
||||||
|
@ -108,12 +108,12 @@ namespace NzbDrone.Host
|
|||||||
return ApplicationModes.Help;
|
return ApplicationModes.Help;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OsInfo.IsMono && startupContext.InstallService)
|
if (OsInfo.IsWindows && startupContext.InstallService)
|
||||||
{
|
{
|
||||||
return ApplicationModes.InstallService;
|
return ApplicationModes.InstallService;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OsInfo.IsMono && startupContext.UninstallService)
|
if (OsInfo.IsWindows && startupContext.UninstallService)
|
||||||
{
|
{
|
||||||
return ApplicationModes.UninstallService;
|
return ApplicationModes.UninstallService;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace NzbDrone.Host
|
|||||||
|
|
||||||
public static bool IsValidate(IUserAlert userAlert)
|
public static bool IsValidate(IUserAlert userAlert)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ namespace NzbDrone.Test.Common.AutoMoq
|
|||||||
{
|
{
|
||||||
var assemblyName = "NzbDrone.Windows";
|
var assemblyName = "NzbDrone.Windows";
|
||||||
|
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
assemblyName = "NzbDrone.Mono";
|
assemblyName = "NzbDrone.Mono";
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ namespace NzbDrone.Test.Common
|
|||||||
|
|
||||||
var nzbdroneConsoleExe = "NzbDrone.Console.exe";
|
var nzbdroneConsoleExe = "NzbDrone.Console.exe";
|
||||||
|
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
nzbdroneConsoleExe = "NzbDrone.exe";
|
nzbdroneConsoleExe = "NzbDrone.exe";
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace NzbDrone.Test.Common
|
|||||||
{
|
{
|
||||||
public static string AsOsAgnostic(this string path)
|
public static string AsOsAgnostic(this string path)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
if (path.Length > 2 && path[1] == ':')
|
if (path.Length > 2 && path[1] == ':')
|
||||||
{
|
{
|
||||||
|
@ -128,16 +128,15 @@ namespace NzbDrone.Test.Common
|
|||||||
|
|
||||||
protected void WindowsOnly()
|
protected void WindowsOnly()
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
throw new IgnoreException("windows specific test");
|
throw new IgnoreException("windows specific test");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void MonoOnly()
|
protected void MonoOnly()
|
||||||
{
|
{
|
||||||
if (!OsInfo.IsMono)
|
if (OsInfo.IsWindows)
|
||||||
{
|
{
|
||||||
throw new IgnoreException("mono specific test");
|
throw new IgnoreException("mono specific test");
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace NzbDrone.Update.UpdateEngine
|
|||||||
|
|
||||||
public AppType GetAppType()
|
public AppType GetAppType()
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsNotWindows)
|
||||||
{
|
{
|
||||||
//Tehcnically its the console, but its been renamed for mono (Linux/OS X)
|
//Tehcnically its the console, but its been renamed for mono (Linux/OS X)
|
||||||
return AppType.Normal;
|
return AppType.Normal;
|
||||||
|
@ -27,34 +27,31 @@ namespace NzbDrone.Update.UpdateEngine
|
|||||||
|
|
||||||
public void Terminate(int processId)
|
public void Terminate(int processId)
|
||||||
{
|
{
|
||||||
if (OsInfo.IsMono)
|
if (OsInfo.IsWindows)
|
||||||
{
|
{
|
||||||
_logger.Info("Stopping all instances");
|
_logger.Info("Stopping all running services");
|
||||||
_processProvider.Kill(processId);
|
|
||||||
_processProvider.KillAll(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME);
|
|
||||||
_processProvider.KillAll(ProcessProvider.NZB_DRONE_PROCESS_NAME);
|
|
||||||
|
|
||||||
return;
|
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)
|
||||||
|
&& _serviceProvider.IsServiceRunning(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.Info("NzbDrone Service is installed and running");
|
||||||
|
_serviceProvider.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("couldn't stop service", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
_logger.Info("Stopping all running services");
|
|
||||||
|
|
||||||
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)
|
|
||||||
&& _serviceProvider.IsServiceRunning(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
|
||||||
{
|
{
|
||||||
try
|
_processProvider.Kill(processId);
|
||||||
{
|
|
||||||
_logger.Info("NzbDrone Service is installed and running");
|
|
||||||
_serviceProvider.Stop(ServiceProvider.NZBDRONE_SERVICE_NAME);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("couldn't stop service", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Info("Killing all running processes");
|
_logger.Info("Killing all running processes");
|
||||||
|
|
||||||
_processProvider.KillAll(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME);
|
_processProvider.KillAll(ProcessProvider.NZB_DRONE_CONSOLE_PROCESS_NAME);
|
||||||
_processProvider.KillAll(ProcessProvider.NZB_DRONE_PROCESS_NAME);
|
_processProvider.KillAll(ProcessProvider.NZB_DRONE_PROCESS_NAME);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<dt>Version</dt>
|
<dt>Version</dt>
|
||||||
<dd>{{version}}</dd>
|
<dd>{{version}}</dd>
|
||||||
|
|
||||||
{{#if isMono}}
|
{{#if isMonoRuntime}}
|
||||||
<dt>Mono Version</dt>
|
<dt>Mono Version</dt>
|
||||||
<dd>{{runtimeVersion}}</dd>
|
<dd>{{runtimeVersion}}</dd>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
Loading…
Reference in New Issue
Block a user