diff --git a/Installer.iss b/Installer.iss index 4d82e4956..9ef1c7d06 100644 --- a/Installer.iss +++ b/Installer.iss @@ -26,6 +26,7 @@ OutputBaseFilename={#MyOutputFilename} SetupIconFile=src\Jackett.Console\jackett.ico UninstallDisplayIcon={commonappdata}\Jackett\JackettConsole.exe VersionInfoVersion={#MyAppVersion} +UninstallDisplayName={#MyAppName} Compression=lzma SolidCompression=yes DisableDirPage=yes @@ -38,7 +39,7 @@ Name: "windowsService"; Description: "Install as a Windows Service" Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] -Source: "{#MySourceFolder}\Jackett\*"; DestDir: "{commonappdata}\Jackett"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "{#MySourceFolder}\*"; DestDir: "{commonappdata}\Jackett"; Flags: ignoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] @@ -50,13 +51,12 @@ Name: "{commondesktop}\{#MyAppName}"; Filename: "{commonappdata}\Jackett\{#MyApp Filename: "{commonappdata}\Jackett\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent [Run] -Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--Uninstall"; Flags: waituntilterminated; -Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--ReserveUrls"; Flags: waituntilterminated; -Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--MigrateSettings"; Flags: waituntilterminated; -Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--Install"; Flags: waituntilterminated; Tasks: windowsService -Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--Start"; Flags: waituntilterminated; Tasks: windowsService +Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--Uninstall"; Flags: waituntilterminated runhidden; +Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--ReserveUrls"; Flags: waituntilterminated runhidden; +Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--Install"; Flags: waituntilterminated runhidden; Tasks: windowsService +Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--Start"; Flags: waituntilterminated runhidden; Tasks: windowsService [UninstallRun] -Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--Uninstall"; Flags: waituntilterminated skipifdoesntexist +Filename: "{commonappdata}\Jackett\JackettConsole.exe"; Parameters: "--Uninstall"; Flags: waituntilterminated skipifdoesntexist runhidden diff --git a/build.cake b/build.cake index aa2458648..a295bb33c 100644 --- a/build.cake +++ b/build.cake @@ -56,7 +56,11 @@ Task("Build") .IsDependentOn("Restore-NuGet-Packages") .Does(() => { - MSBuild("./src/Jackett.sln", settings => settings.SetConfiguration(configuration)); + var buildSettings = new MSBuildSettings() + .SetConfiguration(configuration) + .UseToolVersion(MSBuildToolVersion.VS2017); + + MSBuild("./src/Jackett.sln", buildSettings); }); Task("Run-Unit-Tests") @@ -86,7 +90,7 @@ Task("Copy-Files-Full-Framework") CopyDirectory("./src/Jackett.Console/bin/" + configuration, windowsOutput); CopyFiles("./src/Jackett.Service/bin/" + configuration + "/JackettService.*", windowsOutput); CopyFiles("./src/Jackett.Tray/bin/" + configuration + "/JackettTray.*", windowsOutput); - CopyFiles("./src/Jackett.Updater/bin/" + configuration + "/JackettUpdater.*", windowsOutput); + CopyFiles("./src/Jackett.Updater/bin/" + configuration + "/net452" + "/JackettUpdater.*", windowsOutput); //builds against multiple frameworks CopyFiles("./Upstart.config", windowsOutput); CopyFiles("./LICENSE", windowsOutput); CopyFiles("./README.md", windowsOutput); @@ -119,13 +123,13 @@ Task("Package-Windows-Installer-Full-Framework") .IsDependentOn("Check-Packaging-Platform") .Does(() => { - string sourceFolder = MakeAbsolute(Directory(windowsBuildFullFramework)).ToString(); + string sourceFolder = MakeAbsolute(Directory(windowsBuildFullFramework + "/Jackett")).ToString(); InnoSetupSettings settings = new InnoSetupSettings(); settings.OutputDirectory = workingDir + "/" + artifactsDirName; settings.Defines = new Dictionary { - { "MyFileForVersion", sourceFolder + "/Jackett/Jackett.Common.dll" }, + { "MyFileForVersion", sourceFolder + "/Jackett.Common.dll" }, { "MySourceFolder", sourceFolder }, { "MyOutputFilename", "Jackett.Installer.Windows" }, }; @@ -155,7 +159,7 @@ Task("Package-Full-Framework") .IsDependentOn("Package-Files-Full-Framework-Mono") .Does(() => { - Information("Full Framwork Packaging Completed"); + Information("Full Framework Packaging Completed"); }); Task("Experimental-DotNetCore") diff --git a/src/Jackett.Common/Definitions/tntvillage.yml b/src/Jackett.Common/Definitions/tntvillage.yml index 948cfabcd..a7b013068 100644 --- a/src/Jackett.Common/Definitions/tntvillage.yml +++ b/src/Jackett.Common/Definitions/tntvillage.yml @@ -34,15 +34,8 @@ page: 1 srcrel: "{{ .Keywords }}" keywordsfilters: - - name: re_replace - args: ["S[0-9]{2}([^E]|$)", ""] # remove season tag without episode (search doesn't support it) - name: diacritics args: replace - # most ITA TV torrents are in XXxYY format, so we search without S/E prefixes and filter later - - name: re_replace - args: ["S0?(\\d{1,2})", " $1 "] - - name: re_replace - args: ["E(\\d{2,3})", " $1 "] rows: selector: div.showrelease_tb table tbody tr:not(tr:nth-child(1)) fields: @@ -54,27 +47,9 @@ filters: - name: split args: ["=", "-1"] - # inizio prova - - name: re_replace # replace special characters with " " (space) - args: ["[^a-zA-Z0-9]|\\.", " "] # normalize to SXXEYY format - name: re_replace - args: ["(\\d{2})x(\\d{2})", "S$1E$2"] - - name: re_replace - args: ["(\\d{1})x(\\d{2})", "S0$1E$2"] - - name: re_replace #Stagione X --> S0X - args: ["Stagione (\\d{0,1}\\s)", "S0$1"] - - name: re_replace #Stagione XX --> SXX - args: ["Stagione (\\d{2}\\s)", "S$1"] - - name: re_replace #/ Episodio [YY-YY --> EYY-YY - args: ["(\\s\\/\\sEpisodio|\\s\\/\\sEpisodi|\\sEpisodio|\\s\\|\\sEpisodio|\\sEpisodi)\\s\\[", "E"] - - name: re_replace #/ Completa [episodi YY-YY --> EYY-YY - args: ["(\\s\\/\\sCompleta\\s\\[episodi\\s)", "E"] - - name: re_replace #remove di YY] | remove /YY] - args: ["(\\sdi\\s\\d{1,2}|\\/\\d{1,2})\\]", " "] - - name: re_replace #remove various - args: ["(Serie completa|Completa|\\[in pausa\\])", ""] - # fine prova + args: ["\\b([s])?(\\d{1,3})[x\\s](\\d{1,3})", "S$2E$3"] details: selector: td:nth-child(7) a attribute: href diff --git a/src/Jackett.Common/Indexers/BaseIndexer.cs b/src/Jackett.Common/Indexers/BaseIndexer.cs index e45b01ae2..c7d4f3cb9 100644 --- a/src/Jackett.Common/Indexers/BaseIndexer.cs +++ b/src/Jackett.Common/Indexers/BaseIndexer.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using AutoMapper; +using AutoMapper; using Jackett.Common.Models; using Jackett.Common.Models.IndexerConfig; using Jackett.Common.Services.Interfaces; @@ -14,6 +7,12 @@ using Jackett.Common.Utils.Clients; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; namespace Jackett.Common.Indexers { @@ -184,10 +183,10 @@ namespace Jackett.Common.Indexers return false; } - Version dotNetVersion = Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.RuntimeFramework.Version; + bool runningOnDotNetCore = RuntimeInformation.FrameworkDescription.IndexOf("core", StringComparison.OrdinalIgnoreCase) >= 0; bool isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; - if (!isWindows && dotNetVersion.Major < 4) + if (!isWindows && runningOnDotNetCore) { // User isn't running Windows, but is running on .NET Core framework, no access to the DPAPI, so don't bother trying to migrate return false; @@ -290,7 +289,7 @@ namespace Jackett.Common.Indexers return false; if (caps.SupportsImdbSearch && query.IsImdbQuery) return true; - else if(!caps.SupportsImdbSearch && query.IsImdbQuery && query.QueryType != "TorrentPotato") // potato query should always contain imdb+search term + else if (!caps.SupportsImdbSearch && query.IsImdbQuery && query.QueryType != "TorrentPotato") // potato query should always contain imdb+search term return false; if (caps.SearchAvailable && query.IsSearch) return true; @@ -838,7 +837,6 @@ namespace Jackett.Common.Indexers public override TorznabCapabilities TorznabCaps { get; protected set; } - private List categoryMapping = new List(); protected WebClient webclient; protected readonly string downloadUrlBase = ""; diff --git a/src/Jackett.Common/Indexers/Fuzer.cs b/src/Jackett.Common/Indexers/Fuzer.cs index 77e1db088..9530b3196 100644 --- a/src/Jackett.Common/Indexers/Fuzer.cs +++ b/src/Jackett.Common/Indexers/Fuzer.cs @@ -23,9 +23,9 @@ namespace Jackett.Common.Indexers private string LoginUrl { get { return SiteLink + "login.php"; } } private const int MAXPAGES = 3; - private new ConfigurationDataBasicLogin configData + private new ConfigurationDataRecaptchaLogin configData { - get { return (ConfigurationDataBasicLogin)base.configData; } + get { return (ConfigurationDataRecaptchaLogin)base.configData; } set { base.configData = value; } } @@ -37,7 +37,7 @@ namespace Jackett.Common.Indexers client: w, logger: l, p: ps, - configData: new ConfigurationDataBasicLogin()) + configData: new ConfigurationDataRecaptchaLogin()) { Encoding = Encoding.GetEncoding("windows-1255"); Language = "he-il"; @@ -95,9 +95,57 @@ namespace Jackett.Common.Indexers AddCategoryMapping(76, TorznabCatType.TV, "סדרות"); } + public override async Task GetConfigurationForSetup() + { + var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty); + CQ cq = loginPage.Content; + var captcha = cq.Find(".g-recaptcha"); // invisible recaptcha + if (captcha.Any()) + { + var result = this.configData; + result.CookieHeader.Value = loginPage.Cookies; + result.Captcha.SiteKey = captcha.Attr("data-sitekey"); + result.Captcha.Version = "2"; + return result; + } + else + { + var result = new ConfigurationDataBasicLogin(); + result.SiteLink.Value = configData.SiteLink.Value; + result.Instructions.Value = configData.Instructions.Value; + result.Username.Value = configData.Username.Value; + result.Password.Value = configData.Password.Value; + result.CookieHeader.Value = loginPage.Cookies; + return result; + } + } + public override async Task ApplyConfiguration(JToken configJson) { LoadValuesFromJson(configJson); + + if (!string.IsNullOrWhiteSpace(configData.Captcha.Cookie)) + { + CookieHeader = configData.Captcha.Cookie; + try + { + var results = await PerformQuery(new TorznabQuery()); + if (results.Count() == 0) + { + throw new Exception("Your cookie did not work"); + } + + IsConfigured = true; + SaveConfig(); + return IndexerConfigurationStatus.Completed; + } + catch (Exception e) + { + IsConfigured = false; + throw new Exception("Your cookie did not work: " + e.Message); + } + } + var loginPage = await RequestStringWithCookies(LoginUrl, string.Empty); var pairs = new Dictionary { diff --git a/src/Jackett.Common/Jackett.Common.csproj b/src/Jackett.Common/Jackett.Common.csproj index c49fbccad..f72532bb8 100644 --- a/src/Jackett.Common/Jackett.Common.csproj +++ b/src/Jackett.Common/Jackett.Common.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net452 + netstandard2.0;net452;net461 0.0.0 @@ -121,7 +121,6 @@ - @@ -189,7 +188,8 @@ - + + diff --git a/src/Jackett.Common/Services/UpdateService.cs b/src/Jackett.Common/Services/UpdateService.cs index 36b1a0baa..a3c808d1d 100644 --- a/src/Jackett.Common/Services/UpdateService.cs +++ b/src/Jackett.Common/Services/UpdateService.cs @@ -98,6 +98,12 @@ namespace Jackett.Common.Services return; } + bool trayIsRunning = false; + if (isWindows) + { + trayIsRunning = Process.GetProcessesByName("JackettTray").Length > 0; + } + try { @@ -135,7 +141,7 @@ namespace Jackett.Common.Services var installDir = Path.GetDirectoryName(ExePath()); var updaterPath = Path.Combine(tempDir, "Jackett", "JackettUpdater.exe"); if (updaterPath != null) - StartUpdate(updaterPath, installDir, isWindows, serverConfig.RuntimeSettings.NoRestart); + StartUpdate(updaterPath, installDir, isWindows, serverConfig.RuntimeSettings.NoRestart, trayIsRunning); } catch (Exception e) { @@ -212,7 +218,7 @@ namespace Jackett.Common.Services private async Task DownloadRelease(List assets, bool isWindows, string version) { - var targetAsset = assets.Where(a => isWindows ? a.Browser_download_url.ToLowerInvariant().EndsWith(".zip") : a.Browser_download_url.ToLowerInvariant().EndsWith(".gz")).FirstOrDefault(); + var targetAsset = assets.Where(a => isWindows ? a.Browser_download_url.EndsWith(".zip", StringComparison.OrdinalIgnoreCase) : a.Browser_download_url.EndsWith(".gz", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (targetAsset == null) { @@ -262,7 +268,7 @@ namespace Jackett.Common.Services return tempDir; } - private void StartUpdate(string updaterExePath, string installLocation, bool isWindows, bool NoRestart) + private void StartUpdate(string updaterExePath, string installLocation, bool isWindows, bool NoRestart, bool trayWasRunning) { var exe = Path.GetFileName(ExePath()); var args = string.Join(" ", Environment.GetCommandLineArgs().Skip(1).Select(a => a.Contains(" ") ? "\"" +a + "\"" : a )).Replace("\"", "\\\""); @@ -298,7 +304,14 @@ namespace Jackett.Common.Services } if (NoRestart) + { startInfo.Arguments += " --NoRestart"; + } + + if (trayWasRunning) + { + startInfo.Arguments += " --StartTray"; + } logger.Info($"Starting updater: {startInfo.FileName} {startInfo.Arguments}"); var procInfo = Process.Start(startInfo); diff --git a/src/Jackett.Common/Utils/EnvironmentUtil.cs b/src/Jackett.Common/Utils/EnvironmentUtil.cs index a9b3e2880..385d5bbdd 100644 --- a/src/Jackett.Common/Utils/EnvironmentUtil.cs +++ b/src/Jackett.Common/Utils/EnvironmentUtil.cs @@ -32,17 +32,7 @@ namespace Jackett.Common.Utils try { - var currentAssembly = Assembly.GetExecutingAssembly(); - - bool aspNetCorePresent = new StackTrace().GetFrames() - .Select(x => x.GetMethod().ReflectedType.Assembly).Distinct() - .Where(x => x.GetReferencedAssemblies().Any(y => y.FullName == currentAssembly.FullName)) - .Where(x => x.ManifestModule.Name == "JackettConsole.exe").Select(x => x.CustomAttributes) - .FirstOrDefault() - .Where(x => x.AttributeType.Assembly.FullName.StartsWith("Microsoft.AspNetCore", StringComparison.OrdinalIgnoreCase)) - .Any(); - - runningOwin = !aspNetCorePresent; + runningOwin = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.StartsWith("Jackett, ")).Any(); } catch { diff --git a/src/Jackett.Updater/App.config b/src/Jackett.Updater/App.config deleted file mode 100644 index 6d65ca7c1..000000000 --- a/src/Jackett.Updater/App.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/Jackett.Updater/Jackett.Updater.csproj b/src/Jackett.Updater/Jackett.Updater.csproj index 221b75bcd..11715844d 100644 --- a/src/Jackett.Updater/Jackett.Updater.csproj +++ b/src/Jackett.Updater/Jackett.Updater.csproj @@ -1,88 +1,14 @@ - - - - - Debug - AnyCPU - {A61E311A-6F8B-4497-B5E4-2EA8994C7BD8} - Exe - Properties - Jackett.Updater - JackettUpdater - v4.5.2 - 512 - true - PackageReference - win - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - + + + net452;net461;netcoreapp2.1 jackett.ico + JackettUpdater + Exe + - - - - - - - - - - - - - - - + - - - - - - - - Designer - - - - - {6B854A1B-9A90-49C0-BC37-9A35C75BCA73} - Jackett.Common - - - {e636d5f8-68b4-4903-b4ed-ccfd9c9e899f} - Jackett - - - - - - - + \ No newline at end of file diff --git a/src/Jackett.Updater/Program.cs b/src/Jackett.Updater/Program.cs index babe31a9d..16a0a8025 100644 --- a/src/Jackett.Updater/Program.cs +++ b/src/Jackett.Updater/Program.cs @@ -1,34 +1,51 @@ using CommandLine; using CommandLine.Text; using Jackett.Common.Models.Config; -using Jackett.Services; +using Jackett.Common.Services; +using Jackett.Common.Services.Interfaces; +using Jackett.Common.Utils; +using NLog; using System; using System.Diagnostics; using System.IO; using System.Linq; +using System.Net; using System.Reflection; -using System.Web; -using Jackett.Common; namespace Jackett.Updater { - class Program + public class Program { - static void Main(string[] args) + private IProcessService processService; + private IServiceConfigService windowsService; + private Logger logger; + + public static void Main(string[] args) { new Program().Run(args); } private void Run(string[] args) { - Engine.BuildContainer(new RuntimeSettings() + RuntimeSettings runtimeSettings = new RuntimeSettings() { CustomLogFileName = "updater.txt" - }); - Engine.Logger.Info("Jackett Updater v" + GetCurrentVersion()); - Engine.Logger.Info("Options \"" + string.Join("\" \"", args) + "\""); - try { - var optionsResult = Parser.Default.ParseArguments(args); + }; + + LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings); + logger = LogManager.GetCurrentClassLogger(); + + logger.Info("Jackett Updater v" + GetCurrentVersion()); + logger.Info("Options \"" + string.Join("\" \"", args) + "\""); + + processService = new ProcessService(logger); + windowsService = new WindowsServiceConfigService(processService, logger); + + var commandLineParser = new Parser(settings => settings.CaseSensitive = false); + + try + { + var optionsResult = commandLineParser.ParseArguments(args); optionsResult.WithParsed(options => { ProcessUpdate(options); @@ -36,14 +53,14 @@ namespace Jackett.Updater ); optionsResult.WithNotParsed(errors => { - Engine.Logger.Error(HelpText.AutoBuild(optionsResult)); - Engine.Logger.Error("Failed to process update arguments!"); + logger.Error(HelpText.AutoBuild(optionsResult)); + logger.Error("Failed to process update arguments!"); Console.ReadKey(); }); } catch (Exception e) { - Engine.Logger.Error(e, "Exception applying update!"); + logger.Error(e, "Exception applying update!"); } } @@ -61,21 +78,20 @@ namespace Jackett.Updater try { var proc = Process.GetProcessById(pid); - Engine.Logger.Info("Killing process " + proc.Id); + logger.Info("Killing process " + proc.Id); proc.Kill(); var exited = proc.WaitForExit(5000); if (!exited) - Engine.Logger.Info("Process " + pid.ToString() + " didn't exit within 5 seconds"); - + logger.Info("Process " + pid.ToString() + " didn't exit within 5 seconds"); } catch (ArgumentException) { - Engine.Logger.Info("Process " + pid.ToString() + " is already dead"); + logger.Info("Process " + pid.ToString() + " is already dead"); } catch (Exception e) { - Engine.Logger.Info("Error killing process " + pid.ToString()); - Engine.Logger.Info(e); + logger.Info("Error killing process " + pid.ToString()); + logger.Info(e); } } } @@ -83,7 +99,7 @@ namespace Jackett.Updater private void ProcessUpdate(UpdaterConsoleOptions options) { var updateLocation = GetUpdateLocation(); - if(!(updateLocation.EndsWith("\\") || updateLocation.EndsWith("/"))) + if (!(updateLocation.EndsWith("\\") || updateLocation.EndsWith("/"))) { updateLocation += Path.DirectorySeparatorChar; } @@ -95,18 +111,18 @@ namespace Jackett.Updater pids = Array.ConvertAll(pidsStr, pid => int.Parse(pid)); } - var isWindows = System.Environment.OSVersion.Platform != PlatformID.Unix; + var isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; var trayRunning = false; var trayProcesses = Process.GetProcessesByName("JackettTray"); if (isWindows) { if (trayProcesses.Count() > 0) - { + { foreach (var proc in trayProcesses) { try { - Engine.Logger.Info("Killing tray process " + proc.Id); + logger.Info("Killing tray process " + proc.Id); proc.Kill(); trayRunning = true; } @@ -118,9 +134,9 @@ namespace Jackett.Updater // On unix we kill the PIDs after the update so e.g. systemd can automatically restart the process KillPids(pids); } - Engine.Logger.Info("Finding files in: " + updateLocation); + logger.Info("Finding files in: " + updateLocation); var files = Directory.GetFiles(updateLocation, "*.*", SearchOption.AllDirectories); - foreach(var file in files) + foreach (var file in files) { var fileName = Path.GetFileName(file).ToLowerInvariant(); @@ -130,20 +146,21 @@ namespace Jackett.Updater { continue; } - try { - Engine.Logger.Info("Copying " + fileName); + try + { + logger.Info("Copying " + fileName); var dest = Path.Combine(options.Path, file.Substring(updateLocation.Length)); var destDir = Path.GetDirectoryName(dest); if (!Directory.Exists(destDir)) { - Engine.Logger.Info("Creating directory " + destDir); + logger.Info("Creating directory " + destDir); Directory.CreateDirectory(destDir); } File.Copy(file, dest, true); } - catch(Exception e) + catch (Exception e) { - Engine.Logger.Error(e); + logger.Error(e); } } @@ -157,17 +174,16 @@ namespace Jackett.Updater var deleteDir = Path.Combine(options.Path, oldDir); if (Directory.Exists(deleteDir)) { - Engine.Logger.Info("Deleting directory " + deleteDir); + logger.Info("Deleting directory " + deleteDir); Directory.Delete(deleteDir, true); } } catch (Exception e) { - Engine.Logger.Error(e); + logger.Error(e); } } - // delete old files string[] oldFiles = new string[] { "Content/css/jquery.dataTables.css", @@ -209,20 +225,20 @@ namespace Jackett.Updater "Definitions/torrentwtf.yml", }; - foreach (var oldFIle in oldFiles) + foreach (var oldFile in oldFiles) { try { - var deleteFile = Path.Combine(options.Path, oldFIle); + var deleteFile = Path.Combine(options.Path, oldFile); if (File.Exists(deleteFile)) { - Engine.Logger.Info("Deleting file " + deleteFile); + logger.Info("Deleting file " + deleteFile); File.Delete(deleteFile); } } catch (Exception e) { - Engine.Logger.Error(e); + logger.Error(e); } } @@ -232,7 +248,7 @@ namespace Jackett.Updater if (options.NoRestart == false) { - if (trayRunning) + if (trayRunning || options.StartTray) { var startInfo = new ProcessStartInfo() { @@ -242,16 +258,22 @@ namespace Jackett.Updater }; Process.Start(startInfo); + + if (!windowsService.ServiceExists()) + { + //User was running the tray icon, but not using the Windows service, starting Tray icon will start JackettConsole as well + return; + } } - if(string.Equals(options.Type, "JackettService.exe", StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(options.Type, "JackettService.exe", StringComparison.InvariantCultureIgnoreCase)) { - var serviceHelper = new ServiceConfigService(null, null); - if (serviceHelper.ServiceExists()) + if (windowsService.ServiceExists()) { - serviceHelper.Start(); + windowsService.Start(); } - } else + } + else { var startInfo = new ProcessStartInfo() { @@ -266,7 +288,7 @@ namespace Jackett.Updater startInfo.FileName = "mono"; } - Engine.Logger.Info("Starting Jackett: " + startInfo.FileName + " " + startInfo.Arguments); + logger.Info("Starting Jackett: " + startInfo.FileName + " " + startInfo.Arguments); Process.Start(startInfo); } } @@ -275,7 +297,7 @@ namespace Jackett.Updater private string GetUpdateLocation() { var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase); - return new FileInfo(HttpUtility.UrlDecode(location.AbsolutePath)).DirectoryName; + return new FileInfo(WebUtility.UrlDecode(location.AbsolutePath)).DirectoryName; } } } diff --git a/src/Jackett.Updater/Properties/AssemblyInfo.cs b/src/Jackett.Updater/Properties/AssemblyInfo.cs deleted file mode 100644 index abbc39bda..000000000 --- a/src/Jackett.Updater/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Jackett.Updater")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Jackett.Updater")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a61e311a-6f8b-4497-b5e4-2ea8994c7bd8")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.0.0.0")] -[assembly: AssemblyFileVersion("0.0.0.0")] diff --git a/src/Jackett.Updater/UpdaterConsoleOptions.cs b/src/Jackett.Updater/UpdaterConsoleOptions.cs index 92cc06330..6baf43d2c 100644 --- a/src/Jackett.Updater/UpdaterConsoleOptions.cs +++ b/src/Jackett.Updater/UpdaterConsoleOptions.cs @@ -18,5 +18,8 @@ namespace Jackett.Updater [Option("KillPids", HelpText = "PIDs which will be killed before (Windows) or after (Unix) the update")] public string KillPids { get; set; } + + [Option("StartTray", HelpText = "Indicates that the updater should start the tray icon")] + public bool StartTray { get; set; } } }