Code tidy up

This commit is contained in:
flightlevel
2019-03-06 20:20:32 +11:00
parent 6ac9555cb5
commit a5f0e2b5db
2 changed files with 16 additions and 17 deletions

View File

@@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
namespace Jackett.Common.Utils namespace Jackett.Common.Utils
{ {
@@ -67,7 +65,6 @@ namespace Jackett.Common.Utils
return JackettVariant.NotFound; return JackettVariant.NotFound;
} }
public string GetArtifactFileName(JackettVariant variant) public string GetArtifactFileName(JackettVariant variant)
{ {
switch (variant) switch (variant)

View File

@@ -19,7 +19,7 @@ namespace Jackett.Updater
private IProcessService processService; private IProcessService processService;
private IServiceConfigService windowsService; private IServiceConfigService windowsService;
private Logger logger; private Logger logger;
Variants.JackettVariant variant = Variants.JackettVariant.NotFound; private Variants.JackettVariant variant = Variants.JackettVariant.NotFound;
public static void Main(string[] args) public static void Main(string[] args)
{ {
@@ -68,6 +68,7 @@ namespace Jackett.Updater
{ {
logger.Error(HelpText.AutoBuild(optionsResult)); logger.Error(HelpText.AutoBuild(optionsResult));
logger.Error("Failed to process update arguments!"); logger.Error("Failed to process update arguments!");
logger.Error(errors.ToString());
Console.ReadKey(); Console.ReadKey();
}); });
} }
@@ -99,9 +100,11 @@ namespace Jackett.Updater
{ {
try try
{ {
var startInfo = new ProcessStartInfo(); var startInfo = new ProcessStartInfo
startInfo.Arguments = "-15 " + pid; {
startInfo.FileName = "kill"; Arguments = "-15 " + pid,
FileName = "kill"
};
Process.Start(startInfo); Process.Start(startInfo);
System.Threading.Thread.Sleep(1000); // just sleep, WaitForExit() doesn't seem to work on mono/linux (returns immediantly), https://bugzilla.xamarin.com/show_bug.cgi?id=51742 System.Threading.Thread.Sleep(1000); // just sleep, WaitForExit() doesn't seem to work on mono/linux (returns immediantly), https://bugzilla.xamarin.com/show_bug.cgi?id=51742
exited = proc.WaitForExit(2000); exited = proc.WaitForExit(2000);
@@ -153,7 +156,7 @@ namespace Jackett.Updater
var trayProcesses = Process.GetProcessesByName("JackettTray"); var trayProcesses = Process.GetProcessesByName("JackettTray");
if (isWindows) if (isWindows)
{ {
if (trayProcesses.Count() > 0) if (trayProcesses.Length > 0)
{ {
foreach (var proc in trayProcesses) foreach (var proc in trayProcesses)
{ {
@@ -177,9 +180,9 @@ namespace Jackett.Updater
{ {
var fileName = Path.GetFileName(file).ToLowerInvariant(); var fileName = Path.GetFileName(file).ToLowerInvariant();
if (fileName.EndsWith(".zip") || if (fileName.EndsWith(".zip")
fileName.EndsWith(".tar") || || fileName.EndsWith(".tar")
fileName.EndsWith(".gz")) || fileName.EndsWith(".gz"))
{ {
continue; continue;
} }
@@ -308,7 +311,7 @@ namespace Jackett.Updater
if (!isWindows) if (!isWindows)
KillPids(pids); KillPids(pids);
if (options.NoRestart == false) if (!options.NoRestart)
{ {
if (isWindows && (trayRunning || options.StartTray) && !string.Equals(options.Type, "WindowsService", StringComparison.OrdinalIgnoreCase)) if (isWindows && (trayRunning || options.StartTray) && !string.Equals(options.Type, "WindowsService", StringComparison.OrdinalIgnoreCase))
{ {
@@ -349,7 +352,6 @@ namespace Jackett.Updater
logger.Error("Failed to get admin rights to start the service."); logger.Error("Failed to get admin rights to start the service.");
} }
} }
} }
else else
{ {
@@ -389,8 +391,8 @@ namespace Jackett.Updater
private string GetJackettConsolePath(string directoryPath) private string GetJackettConsolePath(string directoryPath)
{ {
if (variant == Variants.JackettVariant.CoreMacOs || variant == Variants.JackettVariant.CoreLinuxAmdx64 || if (variant == Variants.JackettVariant.CoreMacOs || variant == Variants.JackettVariant.CoreLinuxAmdx64
variant == Variants.JackettVariant.CoreLinuxArm32 || variant == Variants.JackettVariant.CoreLinuxArm64) || variant == Variants.JackettVariant.CoreLinuxArm32 || variant == Variants.JackettVariant.CoreLinuxArm64)
{ {
return Path.Combine(directoryPath, "jackett"); return Path.Combine(directoryPath, "jackett");
} }