public Ticket(int ticketId, long refNr, Variants type, DateTime arrived) { _ticketId = ticketId; _rad = 0; _sete = 0; _navn = ""; _type = type; _arrived = arrived; _refNr = refNr; }
public Ticket(int ticketId, int rad, int sete, string navn, long refNr, Variants type, DateTime arrived) { _ticketId = ticketId; _rad = rad; _sete = sete; _navn = navn; _type = type; _arrived = arrived; _refNr = refNr; }
public bool Any() { return(Variants?.Any() ?? false); }
private async Task <string> DownloadRelease(List <Asset> assets, bool isWindows, string version) { var variants = new Variants(); var artifactFileName = variants.GetArtifactFileName(variant); var targetAsset = assets.FirstOrDefault(a => a.Browser_download_url.EndsWith(artifactFileName, StringComparison.OrdinalIgnoreCase) && artifactFileName.Length > 0); if (targetAsset == null) { logger.Error("Failed to find asset to download!"); return(null); } var url = targetAsset.Browser_download_url; var data = await client.GetBytes(SetDownloadHeaders(new WebRequest() { Url = url, EmulateBrowser = true, Type = RequestType.GET })); while (data.IsRedirect) { data = await client.GetBytes(new WebRequest() { Url = data.RedirectingTo, EmulateBrowser = true, Type = RequestType.GET }); } var tempDir = Path.Combine(Path.GetTempPath(), "JackettUpdate-" + version + "-" + DateTime.Now.Ticks); if (Directory.Exists(tempDir)) { Directory.Delete(tempDir, true); } Directory.CreateDirectory(tempDir); if (isWindows) { var zipPath = Path.Combine(tempDir, "Update.zip"); File.WriteAllBytes(zipPath, data.Content); var fastZip = new FastZip(); fastZip.ExtractZip(zipPath, tempDir, null); } else { var gzPath = Path.Combine(tempDir, "Update.tar.gz"); File.WriteAllBytes(gzPath, data.Content); Stream inStream = File.OpenRead(gzPath); Stream gzipStream = new GZipInputStream(inStream); var tarArchive = TarArchive.CreateInputTarArchive(gzipStream); tarArchive.ExtractContents(tempDir); tarArchive.Close(); gzipStream.Close(); inStream.Close(); if (variant == Variants.JackettVariant.CoreMacOs || variant == Variants.JackettVariant.CoreLinuxAmdx64 || variant == Variants.JackettVariant.CoreLinuxArm32 || variant == Variants.JackettVariant.CoreLinuxArm64 || variant == Variants.JackettVariant.Mono) { //Calling the file permission service to limit usage to netcoreapp. The Mono.Posix.NETStandard library causes issues outside of .NET Core //https://github.com/xamarin/XamarinComponents/issues/282 // When the files get extracted, the execute permission for jackett and JackettUpdater don't get carried across var jackettPath = tempDir + "/Jackett/jackett"; filePermissionService.MakeFileExecutable(jackettPath); var jackettUpdaterPath = tempDir + "/Jackett/JackettUpdater"; filePermissionService.MakeFileExecutable(jackettUpdaterPath); if (variant == Variants.JackettVariant.CoreMacOs) { filePermissionService.MakeFileExecutable(tempDir + "/Jackett/install_service_macos"); filePermissionService.MakeFileExecutable(tempDir + "/Jackett/uninstall_jackett_macos"); } else if (variant == Variants.JackettVariant.Mono) { var systemdPath = tempDir + "/Jackett/install_service_systemd_mono.sh"; filePermissionService.MakeFileExecutable(systemdPath); } else { var systemdPath = tempDir + "/Jackett/install_service_systemd.sh"; filePermissionService.MakeFileExecutable(systemdPath); var launcherPath = tempDir + "/Jackett/jackett_launcher.sh"; filePermissionService.MakeFileExecutable(launcherPath); } } } return(tempDir); }
public void ToWord(IWordAnswerPrinter printer) { printer.AddColumn(Variants.GetRandomizedList()); printer.AddColumn(Accordances.GetRandomizedList()); }
public VariantsBuilder() { variants = new Variants(); variants.stockPoints = new List <StockPoints>(); variants.availlableCountries = new List <Country>(); }
internal Session(Xid id, Variants.Variant variant, IEnvelopeHandler envelopeHandler) { Id = id; Variant = variant; EnvelopeHandler = envelopeHandler; }
public void CanEmptyBrackets(string input, params string[] expected) { var actual = Variants.Expand(input).ToList(); Assert.Equal(expected, actual); }
protected void variantDailog_OnDeleteVariant(object sender, EventArgs e) { if (Variants.Count <= 0) { return; } // Allow modifying issues in idle state only IssueInfo parentIssue = IssueInfoProvider.GetOriginalIssue(IssueID); if ((parentIssue == null) || (parentIssue.IssueStatus != IssueStatusEnum.Idle)) { return; } int currVariant = CurrentVariant; if (Variants.Count > 2) { IssueInfoProvider.DeleteIssueInfo(Variants[currVariant].IssueID); Variants.RemoveAt(currVariant); RaiseVariantDeleted(); } else { if (Variants.Count == 2) { // Remove variant IssueInfoProvider.DeleteIssueInfo(Variants[currVariant].IssueID); Variants.RemoveAt(currVariant); } // Get remaining variant IssueABVariantItem issueVariant = Variants[0]; Variants.Clear(); IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueVariant.IssueID); if (issue != null) { // Transfer all data from child to parent and delete child const string ignoredColumns = ";issueid;issueguid;issuevariantname;"; foreach (string column in parentIssue.ColumnNames) { if (!ignoredColumns.Contains(String.Format(";{0};", column.ToLowerCSafe()))) { parentIssue.SetValue(column, issue.GetValue(column)); } } parentIssue.IssueIsABTest = false; parentIssue.IssueVariantName = null; parentIssue.IssueVariantOfIssueID = 0; IssueInfoProvider.SetIssueInfo(parentIssue); // Delete files from parent issue if any MetaFileInfoProvider.DeleteFiles(parentIssue.IssueID, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE); MetaFileInfoProvider.DeleteFiles(parentIssue.IssueID, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE); // Move attachments (meta files) from child to parent MetaFileInfoProvider.MoveMetaFiles(issue.IssueID, parentIssue.IssueID, IssueInfo.OBJECT_TYPE_VARIANT, ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE); MetaFileInfoProvider.MoveMetaFiles(issue.IssueID, parentIssue.IssueID, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE, IssueInfo.OBJECT_TYPE, ObjectAttachmentsCategories.ISSUE); // Delete last variant IssueInfoProvider.DeleteIssueInfo(issue); OriginalIssueID = parentIssue.IssueID; // A/B variants have been deleted => deleting A/B test itself ABTestInfo abi = ABTestInfoProvider.GetABTestInfoForIssue(OriginalIssueID); ABTestInfoProvider.DeleteABTestInfo(abi); } RaiseVariantDeleted(); } }
void IVariantsRepository.Remove(Variants variants) { _context.Entry(variants).State = System.Data.Entity.EntityState.Deleted; }
public void Initalize() { try { var x = Environment.OSVersion; var runtimedir = RuntimeEnvironment.GetRuntimeDirectory(); logger.Info("Environment version: " + Environment.Version.ToString() + " (" + runtimedir + ")"); logger.Info("OS version: " + Environment.OSVersion.ToString() + (Environment.Is64BitOperatingSystem ? " (64bit OS)" : "") + (Environment.Is64BitProcess ? " (64bit process)" : "")); Variants variants = new Variants(); Variants.JackettVariant variant = variants.GetVariant(); logger.Info("Jackett variant: " + variant.ToString()); try { ThreadPool.GetMaxThreads(out int workerThreads, out int completionPortThreads); logger.Info("ThreadPool MaxThreads: " + workerThreads + " workerThreads, " + completionPortThreads + " completionPortThreads"); } catch (Exception e) { logger.Error("Error while getting MaxThreads details: " + e); } logger.Info("App config/log directory: " + configService.GetAppDataFolder()); try { var issuefile = "/etc/issue"; if (File.Exists(issuefile)) { using (StreamReader reader = new StreamReader(issuefile)) { string firstLine = reader.ReadLine(); if (firstLine != null) { logger.Info("issue: " + firstLine); } } } } catch (Exception e) { logger.Error(e, "Error while reading the issue file"); } Type monotype = Type.GetType("Mono.Runtime"); if (monotype != null && !DotNetCoreUtil.IsRunningOnDotNetCore) { MethodInfo displayName = monotype.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); var monoVersion = "unknown"; if (displayName != null) { monoVersion = displayName.Invoke(null, null).ToString(); } logger.Info("mono version: " + monoVersion); var monoVersionO = new Version(monoVersion.Split(' ')[0]); if (monoVersionO.Major < 5 || (monoVersionO.Major == 5 && monoVersionO.Minor < 8)) { //Hard minimum of 5.8 //5.4 throws a SIGABRT, looks related to this which was fixed in 5.8 https://bugzilla.xamarin.com/show_bug.cgi?id=60625 logger.Error("Your mono version is too old. Please update to the latest version from http://www.mono-project.com/download/"); Environment.Exit(2); } if (monoVersionO.Major < 5 || (monoVersionO.Major == 5 && monoVersionO.Minor < 8)) { string notice = "A minimum Mono version of 5.8 is required. Please update to the latest version from http://www.mono-project.com/download/"; _notices.Add(notice); logger.Error(notice); } try { // Check for mono-devel // Is there any better way which doesn't involve a hard cashes? var mono_devel_file = Path.Combine(runtimedir, "mono-api-info.exe"); if (!File.Exists(mono_devel_file)) { var notice = "It looks like the mono-devel package is not installed, please make sure it's installed to avoid crashes."; _notices.Add(notice); logger.Error(notice); } } catch (Exception e) { logger.Error(e, "Error while checking for mono-devel"); } try { // Check for ca-certificates-mono var mono_cert_file = Path.Combine(runtimedir, "cert-sync.exe"); if (!File.Exists(mono_cert_file)) { var notice = "The ca-certificates-mono package is not installed, HTTPS trackers won't work. Please install it."; _notices.Add(notice); logger.Error(notice); } } catch (Exception e) { logger.Error(e, "Error while checking for ca-certificates-mono"); } try { Encoding.GetEncoding("windows-1255"); } catch (NotSupportedException e) { logger.Debug(e); logger.Error(e.Message + " Most likely the mono-locale-extras package is not installed."); Environment.Exit(2); } // check if the certificate store was initialized using Mono.Security.X509.X509StoreManager.TrustedRootCertificates.Count try { var monoSecurity = Assembly.Load("Mono.Security"); Type monoX509StoreManager = monoSecurity.GetType("Mono.Security.X509.X509StoreManager"); if (monoX509StoreManager != null) { var TrustedRootCertificatesProperty = monoX509StoreManager.GetProperty("TrustedRootCertificates"); var TrustedRootCertificates = (ICollection)TrustedRootCertificatesProperty.GetValue(null); logger.Info("TrustedRootCertificates count: " + TrustedRootCertificates.Count); if (TrustedRootCertificates.Count == 0) { var CACertificatesFiles = new string[] { "/etc/ssl/certs/ca-certificates.crt", // Debian based "/etc/pki/tls/certs/ca-bundle.c", // RedHat based "/etc/ssl/ca-bundle.pem", // SUSE }; var notice = "The mono certificate store is not initialized.<br/>\n"; var logSpacer = " "; var CACertificatesFile = CACertificatesFiles.Where(f => File.Exists(f)).FirstOrDefault(); var CommandRoot = "curl -sS https://curl.haxx.se/ca/cacert.pem | cert-sync /dev/stdin"; var CommandUser = "******"; if (CACertificatesFile != null) { CommandRoot = "cert-sync " + CACertificatesFile; CommandUser = "******" + CACertificatesFile; } notice += logSpacer + "Please run the following command as root:<br/>\n"; notice += logSpacer + "<pre>" + CommandRoot + "</pre><br/>\n"; notice += logSpacer + "If you don't have root access or you're running MacOS, please run the following command as the jackett user (" + Environment.UserName + "):<br/>\n"; notice += logSpacer + "<pre>" + CommandUser + "</pre>"; _notices.Add(notice); logger.Error(Regex.Replace(notice, "<.*?>", String.Empty)); } } } catch (Exception e) { logger.Error(e, "Error while chekcing the mono certificate store"); } } } catch (Exception e) { logger.Error("Error while getting environment details: " + e); } try { if (Environment.UserName == "root") { var notice = "Jackett is running with root privileges. You should run Jackett as an unprivileged user."; _notices.Add(notice); logger.Error(notice); } } catch (Exception e) { logger.Error(e, "Error while checking the username"); } //Warn user that they are using an old version of Jackett try { DateTime compiledData = BuildDate.GetBuildDateTime(); if (compiledData < DateTime.Now.AddMonths(-3)) { string version = configService.GetVersion(); string notice = $"Your version of Jackett v{version} is very old. Multiple indexers are likely to fail when using an old version. Update to the latest version of Jackett."; _notices.Add(notice); logger.Error(notice); } } catch (Exception e) { logger.Error(e, "Error while checking build date of Jackett.Common"); } CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US"); // Load indexers indexerService.InitIndexers(configService.GetCardigannDefinitionsFolders()); client.Init(); updater.CleanupTempDir(); }
public void Initalize() { try { var x = Environment.OSVersion; var runtimedir = RuntimeEnvironment.GetRuntimeDirectory(); logger.Info($"Environment version: {Environment.Version} ({runtimedir})"); logger.Info($"OS version: {Environment.OSVersion}" + (Environment.Is64BitOperatingSystem ? " (64bit OS)" : "") + (Environment.Is64BitProcess ? " (64bit process)" : "")); var variants = new Variants(); var variant = variants.GetVariant(); logger.Info($"Jackett variant: {variant}"); try { var issueFile = "/etc/issue"; if (File.Exists(issueFile)) { using (var reader = new StreamReader(issueFile)) { var firstLine = reader.ReadLine(); if (firstLine != null) { logger.Info($"File {issueFile}: {firstLine}"); } } } } catch (Exception e) { logger.Error($"Error while reading the issue file\n{e}"); } try { var dockerMsg = "No"; const string cgroupFile = "/proc/1/cgroup"; if ((File.Exists(cgroupFile) && File.ReadAllText(cgroupFile).Contains("/docker/")) || File.Exists("/.dockerenv")) { // this file is created in the Docker image build // https://github.com/linuxserver/docker-jackett/pull/105 const string dockerImageFile = "/etc/docker-image"; dockerMsg = File.Exists(dockerImageFile) ? "Yes (image build: " + File.ReadAllText(dockerImageFile).Trim() + ")" : "Yes (image build: unknown)"; } logger.Info($"Running in Docker: {dockerMsg}"); } catch (Exception e) { logger.Error($"Error while reading the Docker cgroup file.\n{e}"); } try { ThreadPool.GetMaxThreads(out var workerThreads, out var completionPortThreads); logger.Info( "ThreadPool MaxThreads: " + workerThreads + " workerThreads, " + completionPortThreads + " completionPortThreads"); } catch (Exception e) { logger.Error("Error while getting MaxThreads details: " + e); } logger.Info("App config/log directory: " + configService.GetAppDataFolder()); logger.Info($"Using proxy: {config.ProxyType}"); logger.Info("Using FlareSolverr: " + (string.IsNullOrEmpty(config.FlareSolverrUrl) ? "No" : config.FlareSolverrUrl)); var monotype = Type.GetType("Mono.Runtime"); if (monotype != null && !DotNetCoreUtil.IsRunningOnDotNetCore) { var displayName = monotype.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); var monoVersion = "unknown"; if (displayName != null) { monoVersion = displayName.Invoke(null, null).ToString(); } logger.Info("Mono version: " + monoVersion); var monoVersionO = new Version(monoVersion.Split(' ')[0]); if (monoVersionO.Major < 5 || (monoVersionO.Major == 5 && monoVersionO.Minor < 8)) { //Hard minimum of 5.8 //5.4 throws a SIGABRT, looks related to this which was fixed in 5.8 https://bugzilla.xamarin.com/show_bug.cgi?id=60625 logger.Error( "Your Mono version is too old. Please update to the latest version from http://www.mono-project.com/download/"); Environment.Exit(2); } if (monoVersionO.Major < 5 || (monoVersionO.Major == 5 && monoVersionO.Minor < 8)) { const string notice = "A minimum Mono version of 5.8 is required. Please update to the latest version from http://www.mono-project.com/download/"; notices.Add(notice); logger.Error(notice); } try { // Check for mono-devel // Is there any better way which doesn't involve a hard cashes? var monoDevelFile = Path.Combine(runtimedir, "mono-api-info.exe"); if (!File.Exists(monoDevelFile)) { const string notice = "It looks like the mono-devel package is not installed, please make sure it's installed to avoid crashes."; notices.Add(notice); logger.Error(notice); } } catch (Exception e) { logger.Error($"Error while checking for mono-devel.\n{e}"); } try { // Check for ca-certificates-mono var monoCertFile = Path.Combine(runtimedir, "cert-sync.exe"); if (!File.Exists(monoCertFile)) { const string notice = "The ca-certificates-mono package is not installed, HTTPS trackers won't work. Please install it."; notices.Add(notice); logger.Error(notice); } } catch (Exception e) { logger.Error($"Error while checking for ca-certificates-mono.\n{e}"); } try { Encoding.GetEncoding("windows-1255"); } catch (NotSupportedException e) { logger.Error($"Most likely the mono-locale-extras package is not installed.\n{e}"); Environment.Exit(2); } if (monoVersionO.Major < 6) { //We don't check on Mono 6 since Mono.Security was removed // check if the certificate store was initialized using Mono.Security.X509.X509StoreManager.TrustedRootCertificates.Count try { var monoSecurity = Assembly.Load("Mono.Security"); var monoX509StoreManager = monoSecurity.GetType("Mono.Security.X509.X509StoreManager"); if (monoX509StoreManager != null) { var trustedRootCertificatesProperty = monoX509StoreManager.GetProperty("TrustedRootCertificates"); var trustedRootCertificates = (ICollection)trustedRootCertificatesProperty.GetValue(null); logger.Info($"TrustedRootCertificates count: {trustedRootCertificates.Count}"); if (trustedRootCertificates.Count == 0) { var caCertificatesFiles = new[] { "/etc/ssl/certs/ca-certificates.crt", // Debian based "/etc/pki/tls/certs/ca-bundle.c", // RedHat based "/etc/ssl/ca-bundle.pem", // SUSE }; const string logSpacer = " "; var notice = "The mono certificate store is not initialized.<br/>\n"; var caCertificatesFile = caCertificatesFiles.Where(File.Exists).FirstOrDefault(); var commandRoot = "curl -sS https://curl.haxx.se/ca/cacert.pem | cert-sync /dev/stdin"; var commandUser = "******"; if (caCertificatesFile != null) { commandRoot = "cert-sync " + caCertificatesFile; commandUser = "******" + caCertificatesFile; } notice += logSpacer + "Please run the following command as root:<br/>\n"; notice += logSpacer + "<pre>" + commandRoot + "</pre><br/>\n"; notice += logSpacer + "If you don't have root access or you're running MacOS, please run the following command as the jackett user (" + Environment.UserName + "):<br/>\n"; notice += logSpacer + "<pre>" + commandUser + "</pre>"; notices.Add(notice); logger.Error(Regex.Replace(notice, "<.*?>", string.Empty)); } } } catch (Exception e) { logger.Error($"Error while chekcing the mono certificate store.\n{e}"); } } } } catch (Exception e) { logger.Error("Error while getting environment details: " + e); } try { if (Environment.UserName == "root") { var notice = "Jackett is running with root privileges. You should run Jackett as an unprivileged user."; notices.Add(notice); logger.Error(notice); } } catch (Exception e) { logger.Error($"Error while checking the username.\n{e}"); } //Warn user that they are using an old version of Jackett try { var compiledData = BuildDate.GetBuildDateTime(); if (compiledData < DateTime.Now.AddMonths(-3)) { var version = configService.GetVersion(); var notice = $"Your version of Jackett {version} is very old. Multiple indexers are likely to fail when using an old version. Update to the latest version of Jackett."; notices.Add(notice); logger.Error(notice); } } catch (Exception e) { logger.Error($"Error while checking build date of Jackett.Common.\n{e}"); } //Alert user that they no longer need to use Mono try { var variants = new Variants(); var variant = variants.GetVariant(); if (variant == Variants.JackettVariant.Mono) { var process = new Process { StartInfo = { FileName = "uname", Arguments = "-m", UseShellExecute = false, RedirectStandardOutput = true } }; process.Start(); var output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); logger.Debug($"uname output was: {output}"); output = output.ToLower(); if (output.Contains("armv7") || output.Contains("armv8") || output.Contains("x86_64")) { isDotNetCoreCapable = true; } } } catch (Exception e) { logger.Debug($"Unable to get architecture.\n{e}"); } CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US"); // Load indexers indexerService.InitIndexers(configService.GetCardigannDefinitionsFolders()); client.Init(); updater.CleanupTempDir(); updater.CheckUpdaterLock(); }
public void SortVariants() { Variants.Sort((variant, translationVariant) => String.Compare(variant.NameRu, translationVariant.NameRu, StringComparison.OrdinalIgnoreCase)); }
private async Task CheckForUpdates() { if (serverConfig.RuntimeSettings.NoUpdates) { logger.Info($"Updates are disabled via --NoUpdates."); return; } if (serverConfig.UpdateDisabled && !forceupdatecheck) { logger.Info($"Skipping update check as it is disabled."); return; } Variants variants = new Variants(); variant = variants.GetVariant(); logger.Info("Jackett variant: " + variant.ToString()); forceupdatecheck = true; var isWindows = System.Environment.OSVersion.Platform != PlatformID.Unix; if (Debugger.IsAttached) { logger.Info($"Skipping checking for new releases as the debugger is attached."); return; } bool trayIsRunning = false; if (isWindows) { trayIsRunning = Process.GetProcessesByName("JackettTray").Length > 0; } try { var response = await client.GetString(new WebRequest() { Url = "https://api.github.com/repos/Jackett/Jackett/releases", Encoding = Encoding.UTF8, EmulateBrowser = false }); if (response.Status != System.Net.HttpStatusCode.OK) { logger.Error("Failed to get the release list: " + response.Status); } var releases = JsonConvert.DeserializeObject <List <Release> >(response.Content); if (!serverConfig.UpdatePrerelease) { releases = releases.Where(r => !r.Prerelease).ToList(); } if (releases.Count > 0) { var latestRelease = releases.OrderByDescending(o => o.Created_at).First(); var currentVersion = $"v{GetCurrentVersion()}"; if (latestRelease.Name != currentVersion && currentVersion != "v0.0.0.0") { logger.Info($"New release found. Current: {currentVersion} New: {latestRelease.Name}"); logger.Info($"Downloading release {latestRelease.Name} It could take a while..."); try { var tempDir = await DownloadRelease(latestRelease.Assets, isWindows, latestRelease.Name); // Copy updater var installDir = Path.GetDirectoryName(ExePath()); var updaterPath = GetUpdaterPath(tempDir); if (updaterPath != null) { StartUpdate(updaterPath, installDir, isWindows, serverConfig.RuntimeSettings.NoRestart, trayIsRunning); } } catch (Exception e) { logger.Error(e, "Error performing update."); } } else { logger.Info($"Checked for a updated release but none was found. Current: {currentVersion} Latest: {latestRelease.Name}"); } } } catch (Exception e) { logger.Error(e, "Error checking for updates."); } finally { if (!isWindows) { System.Net.ServicePointManager.ServerCertificateValidationCallback -= AcceptCert; } } }
private void ProcessUpdate(UpdaterConsoleOptions options) { var updateLocation = EnvironmentUtil.JackettInstallationPath(); if (!(updateLocation.EndsWith("\\") || updateLocation.EndsWith("/"))) { updateLocation += Path.DirectorySeparatorChar; } var pids = new int[] { }; if (options.KillPids != null) { var pidsStr = options.KillPids.Split(',').Where(pid => !string.IsNullOrWhiteSpace(pid)).ToArray(); pids = Array.ConvertAll(pidsStr, pid => int.Parse(pid)); } var isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; var trayRunning = false; var trayProcesses = Process.GetProcessesByName("JackettTray"); if (isWindows) { if (trayProcesses.Length > 0) { foreach (var proc in trayProcesses) { try { logger.Info($"Killing tray process {proc.Id}"); proc.Kill(); trayRunning = true; } catch (Exception e) { logger.Error(e); } } } // on unix we don't have to wait (we can overwrite files which are in use) // On unix we kill the PIDs after the update so e.g. systemd can automatically restart the process KillPids(pids); } var variants = new Variants(); if (variants.IsNonWindowsDotNetCoreVariant(variant)) { // On Linux you can't modify an executable while it is executing // https://github.com/Jackett/Jackett/issues/5022 // https://stackoverflow.com/questions/16764946/what-generates-the-text-file-busy-message-in-unix#comment32135232_16764967 // Delete the ./jackett executable // pdb files are also problematic https://github.com/Jackett/Jackett/issues/5167#issuecomment-489301150 var jackettExecutable = options.Path.TrimEnd('/') + "/jackett"; var pdbFiles = Directory.EnumerateFiles(options.Path, "*.pdb", SearchOption.AllDirectories).ToList(); var removeList = pdbFiles; removeList.Add(jackettExecutable); foreach (var fileForDelete in removeList) { try { logger.Info("Attempting to remove: " + fileForDelete); if (File.Exists(fileForDelete)) { File.Delete(fileForDelete); logger.Info("Deleted " + fileForDelete); } else { logger.Info("File for deleting not found: " + fileForDelete); } } catch (Exception e) { logger.Error(e); } } } logger.Info("Finding files in: " + updateLocation); var files = Directory.GetFiles(updateLocation, "*.*", SearchOption.AllDirectories).OrderBy(x => x).ToList(); logger.Info($"{files.Count} update files found"); try { foreach (var file in files) { var fileName = Path.GetFileName(file).ToLowerInvariant(); if (fileName.EndsWith(".zip") || fileName.EndsWith(".tar") || fileName.EndsWith(".gz")) { continue; } var fileCopySuccess = CopyUpdateFile(options.Path, file, updateLocation, false); if (!fileCopySuccess) //Perform second attempt, this time removing the target file first { CopyUpdateFile(options.Path, file, updateLocation, true); } } } catch (Exception e) { logger.Error(e); } logger.Info("File copying complete"); // delete old dirs var oldDirs = new string[] { "Content/logos" }; foreach (var oldDir in oldDirs) { try { var deleteDir = Path.Combine(options.Path, oldDir); if (Directory.Exists(deleteDir)) { logger.Info("Deleting directory " + deleteDir); Directory.Delete(deleteDir, true); } } catch (Exception e) { logger.Error(e); } } // delete old files var oldFiles = new string[] { "appsettings.Development.json", "Autofac.Integration.WebApi.dll", "Content/congruent_outline.png", "Content/crissXcross.png", "Content/css/jquery.dataTables.css", "Content/css/jquery.dataTables_themeroller.css", "CsQuery.dll", "CurlSharp.dll", "CurlSharp.pdb", "Definitions/32pages.yml", "Definitions/3evils.yml", "Definitions/420files.yml", "Definitions/academictorrents.yml", "Definitions/alein.yml", "Definitions/alexfilm.yml", "Definitions/anidex.yml", // migrated to C# "Definitions/aox.yml", "Definitions/apollo.yml", // migrated to C# gazelle base tracker "Definitions/archetorrent.yml", "Definitions/asgaard.yml", "Definitions/asiandvdclub.yml", "Definitions/ast4u.yml", // renamed to animeworld #10578 "Definitions/audiobooktorrents.yml", // renamed to abtorrents "Definitions/avg.yml", "Definitions/awesomehd.yml", // migrated to C# "Definitions/b2s-share.yml", "Definitions/bithq.yml", "Definitions/bigtower.yml", "Definitions/bitme.yml", "Definitions/bittorrentam.yml", "Definitions/blubits.yml", "Definitions/brobits.yml", "Definitions/bt-scene.yml", "Definitions/btbit.yml", "Definitions/bteye.yml", "Definitions/btgigs.yml", "Definitions/btkitty.yml", "Definitions/btstornet.yml", "Definitions/btxpress.yml", "Definitions/channelx.yml", "Definitions/cili180.yml", // renamed to liaorencili "Definitions/cinefilhd.yml", "Definitions/cooltorrent.yml", "Definitions/crazyscorner.yml", "Definitions/czteam.yml", "Definitions/cztorrent.yml", "Definitions/darmowetorenty.yml", // migrated to C# "Definitions/demonsite.yml", "Definitions/desitorrents.yml", // migrated to C# "Definitions/digbt.yml", "Definitions/documentarytorrents.yml", "Definitions/downloadville.yml", "Definitions/dragonworld.yml", "Definitions/dreamteam.yml", "Definitions/dxdhd.yml", "Definitions/eggmeon.yml", "Definitions/elitehd.yml", "Definitions/elittracker.yml", "Definitions/epizod.yml", "Definitions/eotforum.yml", "Definitions/erzsebet.yml", "Definitions/estrenosdtl.yml", "Definitions/ethor.yml", "Definitions/evolutionpalace.yml", "Definitions/exoticaz.yml", // migrated to C# "Definitions/extratorrent-ag.yml", "Definitions/extratorrentclone.yml", "Definitions/extremlymtorrents.yml", "Definitions/filmsclub.yml", "Definitions/freakstrackingsystem.yml", "Definitions/freedomhd.yml", "Definitions/fullmixmusic.yml", "Definitions/funreleases.yml", "Definitions/galeriens.yml", "Definitions/gdf76.yml", "Definitions/gfxnews.yml", "Definitions/gods.yml", "Definitions/gormogon.yml", "Definitions/greeklegends.yml", "Definitions/hachede.yml", "Definitions/hachede-c.yml", "Definitions/hd4free.yml", "Definitions/hdbc.yml", // renamed to hdbitscom "Definitions/hdclub.yml", "Definitions/hddisk.yml", "Definitions/hdplus.yml", "Definitions/hdreactor.yml", // renamed to hdhouse "Definitions/hdstreet.yml", "Definitions/hon3yhd-net.yml", "Definitions/horriblesubs.yml", "Definitions/horrorsite.yml", "Definitions/hyperay.yml", "Definitions/icetorrent.yml", // migrated to C# XtremeZone base tracker "Definitions/idopeclone.yml", "Definitions/iloveclassics.yml", "Definitions/infinityt.yml", "Definitions/inperil.yml", "Definitions/isohunt.yml", "Definitions/kapaki.yml", "Definitions/katcrs.yml", "Definitions/kaztorka.yml", "Definitions/kickasstorrent.yml", "Definitions/kickasstorrent-kathow.yml", // renamed to kickasstorrents-ws "Definitions/kikibt.yml", "Definitions/korsar.yml", "Definitions/lapausetorrents.yml", "Definitions/leaguehd.yml", // renamed to lemonhd "Definitions/lechaudron.yml", "Definitions/lemencili.yml", "Definitions/leparadisdunet.yml", "Definitions/leporno.yml", "Definitions/liaorencili.yml", // renamed to cilipro "Definitions/magnetdl.yml", "Definitions/maniatorrent.yml", "Definitions/manicomioshare.yml", "Definitions/megabliz.yml", "Definitions/metal-iplay-ro.yml", // renamed to romanianmetaltorrents "Definitions/mkvcage.yml", "Definitions/moecat.yml", "Definitions/monova.yml", "Definitions/movcr.yml", "Definitions/moviezone.yml", // migrated to teracod #9743 "Definitions/music-master.yml", "Definitions/nachtwerk.yml", "Definitions/nexttorrent.yml", "Definitions/nnm-club.yml", // renamed to noname-club "Definitions/nordichd.yml", "Definitions/nostalgic.yml", // renamed to vhstapes "Definitions/nyaa.yml", "Definitions/nyoo.yml", "Definitions/onlineselfeducation.yml", "Definitions/onlyscene.yml", "Definitions/passionetorrent.yml", "Definitions/polishtracker.yml", "Definitions/pt99.yml", "Definitions/qctorrent.yml", "Definitions/qxr.yml", "Definitions/rapidetracker.yml", "Definitions/rarbg.yml", // migrated to C# "Definitions/redtopia.yml", "Definitions/retroflix.yml", // migrated to C# "Definitions/rgu.yml", "Definitions/rns.yml", // site merged with audiobooktorrents "Definitions/rockethd.yml", "Definitions/rockhardlossless.yml", "Definitions/rodvd.yml", "Definitions/scenefz.yml", // migrated to C# XtremeZone base tracker "Definitions/scenehd.yml", // migrated to C# (use JSON API) "Definitions/scenereactor.yml", "Definitions/scenexpress.yml", "Definitions/secretcinema.yml", // migrated to C# gazelle base tracker "Definitions/seedpeer.yml", "Definitions/sharespacedb.yml", "Definitions/shareuniversity.yml", "Definitions/sharingue.yml", "Definitions/shellife.yml", "Definitions/skytorrents.yml", "Definitions/skytorrents-lol.yml", "Definitions/skytorrentsclone.yml", // renamed to skytorrents-lol "Definitions/skytorrentsclone2.yml", // renamed to skytorrents-to "Definitions/solidtorrents.yml", // migrated to C# "Definitions/soundpark.yml", // to be migrated to C# "Definitions/spacetorrent.yml", "Definitions/speed-share.yml", "Definitions/t411.yml", "Definitions/t411v2.yml", "Definitions/takeabyte.yml", "Definitions/tazmaniaden.yml", "Definitions/tenyardtracker.yml", // to be migrated to c#, #795 "Definitions/tbplus.yml", "Definitions/tehconnection.yml", "Definitions/tfile.yml", "Definitions/the-madhouse.yml", "Definitions/themoviecave.yml", "Definitions/thepiratebay.yml", // migrated to c# "Definitions/theresurrection.yml", "Definitions/thetorrents.yml", "Definitions/theunknown.yml", // became 3evils #9678 "Definitions/tigers-dl.yml", "Definitions/tjangto.yml", "Definitions/tntvillage.yml", "Definitions/topnow.yml", "Definitions/torrentbomb.yml", "Definitions/torrentcouch.yml", "Definitions/torrentgalaxyorg.yml", // renamed to torrentgalaxy "Definitions/torrenthane.yml", "Definitions/torrentkim.yml", "Definitions/torrentproject.yml", "Definitions/torrentquest.yml", "Definitions/torrentrex.yml", "Definitions/torrentseed.yml", // renamed to latinop2p #9065 "Definitions/torrentseeds.yml", // migrated to c# "Definitions/torrentsmd.yml", "Definitions/torrentvault.yml", "Definitions/torrentwal.yml", "Definitions/torrentwtf.yml", "Definitions/torrentz2.yml", "Definitions/torrentz2k.yml", "Definitions/torrof.yml", "Definitions/torviet.yml", "Definitions/tspate.yml", "Definitions/turknova.yml", "Definitions/u-torrents.yml", "Definitions/ultimategamerclub.yml", "Definitions/ultrahdclub.yml", "Definitions/uniotaku.yml", // to be migrated to c# "Definitions/utorrents.yml", // same as SzeneFZ now "Definitions/vanila.yml", "Definitions/vhstapes.yml", "Definitions/waffles.yml", "Definitions/world-of-tomorrow.yml", // #9213 "Definitions/worldofp2p.yml", "Definitions/worldwidetorrents.yml", "Definitions/xfsub.yml", "Definitions/xktorrent.yml", "Definitions/xtremefile.yml", "Definitions/xtremezone.yml", // migrated to C# XtremeZone base tracker "Definitions/yingk.yml", "Definitions/yourexotic.yml", // renamed to exoticaz "Microsoft.Owin.dll", "Microsoft.Owin.FileSystems.dll", "Microsoft.Owin.Host.HttpListener.dll", "Microsoft.Owin.Hosting.dll", "Microsoft.Owin.StaticFiles.dll", "Owin.dll", "System.ServiceModel.dll", "System.Web.Http.dll", "System.Web.Http.Owin.dll", "System.Web.Http.Tracing.dll", "System.Xml.XPath.XmlDocument.dll" }; foreach (var oldFile in oldFiles) { try { var deleteFile = Path.Combine(options.Path, oldFile); if (File.Exists(deleteFile)) { logger.Info("Deleting file " + deleteFile); File.Delete(deleteFile); } } catch (Exception e) { logger.Error(e); } } // remove .lock file to detect errors in the update process var lockFilePath = Path.Combine(options.Path, ".lock"); if (File.Exists(lockFilePath)) { File.Delete(lockFilePath); } // kill pids after the update on UNIX if (!isWindows) { KillPids(pids); } if (!options.NoRestart) { if (isWindows && (trayRunning || options.StartTray) && !string.Equals(options.Type, "WindowsService", StringComparison.OrdinalIgnoreCase)) { var startInfo = new ProcessStartInfo() { Arguments = $"--UpdatedVersion \" {EnvironmentUtil.JackettVersion()}\"", FileName = Path.Combine(options.Path, "JackettTray.exe"), UseShellExecute = true }; logger.Info("Starting Tray: " + startInfo.FileName + " " + startInfo.Arguments); 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, "WindowsService", StringComparison.OrdinalIgnoreCase)) { logger.Info("Starting Windows service"); try { windowsService.Start(); } catch { logger.Info("Failed to start service. Attempting to start console."); try { var consolePath = Path.Combine(options.Path, "JackettConsole.exe"); processService.StartProcessAndLog(consolePath, "--Start", true); } catch { logger.Error("Failed to start the service or console."); } } } else { var startInfo = new ProcessStartInfo() { Arguments = options.Args, FileName = GetJackettConsolePath(options.Path), UseShellExecute = true }; if (isWindows) { //User didn't initiate the update from Windows service and wasn't running Jackett via the tray, must have started from the console startInfo.Arguments = $"/K \"{startInfo.FileName}\" {startInfo.Arguments}"; startInfo.FileName = "cmd.exe"; startInfo.CreateNoWindow = false; startInfo.WindowStyle = ProcessWindowStyle.Normal; } if (variant == Variants.JackettVariant.Mono) { startInfo.Arguments = $"\"{startInfo.FileName}\" {startInfo.Arguments}"; startInfo.FileName = "mono"; } if (variant == Variants.JackettVariant.CoreMacOs || variant == Variants.JackettVariant.CoreLinuxAmdx64 || variant == Variants.JackettVariant.CoreLinuxArm32 || variant == Variants.JackettVariant.CoreLinuxArm64) { startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true; } logger.Info($"Starting Jackett: \"{startInfo.FileName }\" {startInfo.Arguments}"); Process.Start(startInfo); } } }
private string GetJackettConsolePath(string directoryPath) { var variants = new Variants(); return(Path.Combine(directoryPath, variants.IsNonWindowsDotNetCoreVariant(variant) ? "jackett" : "JackettConsole.exe")); }
private void ProcessUpdate(UpdaterConsoleOptions options) { var updateLocation = GetUpdateLocation(); if (!(updateLocation.EndsWith("\\") || updateLocation.EndsWith("/"))) { updateLocation += Path.DirectorySeparatorChar; } var pids = new int[] { }; if (options.KillPids != null) { var pidsStr = options.KillPids.Split(',').Where(pid => !string.IsNullOrWhiteSpace(pid)).ToArray(); pids = Array.ConvertAll(pidsStr, pid => int.Parse(pid)); } var isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; var trayRunning = false; var trayProcesses = Process.GetProcessesByName("JackettTray"); if (isWindows) { if (trayProcesses.Length > 0) { foreach (var proc in trayProcesses) { try { logger.Info("Killing tray process " + proc.Id); proc.Kill(); trayRunning = true; } catch { } } } // on unix we don't have to wait (we can overwrite files which are in use) // On unix we kill the PIDs after the update so e.g. systemd can automatically restart the process KillPids(pids); } Variants variants = new Variants(); if (variants.IsNonWindowsDotNetCoreVariant(variant)) { // On Linux you can't modify an executable while it is executing // https://github.com/Jackett/Jackett/issues/5022 // https://stackoverflow.com/questions/16764946/what-generates-the-text-file-busy-message-in-unix#comment32135232_16764967 // Delete the ./jackett executable try { logger.Info("Attempting to remove the jackett executable from: " + options.Path); string executable = options.Path.TrimEnd('/') + "/jackett"; if (File.Exists(executable)) { File.Delete(executable); logger.Info("Deleted " + executable); } else { logger.Info("jackett executable not found in: " + executable); } } catch (Exception e) { logger.Error(e); } } logger.Info("Finding files in: " + updateLocation); var files = Directory.GetFiles(updateLocation, "*.*", SearchOption.AllDirectories); foreach (var file in files) { var fileName = Path.GetFileName(file).ToLowerInvariant(); if (fileName.EndsWith(".zip") || fileName.EndsWith(".tar") || fileName.EndsWith(".gz")) { continue; } try { logger.Info("Copying " + fileName); var dest = Path.Combine(options.Path, file.Substring(updateLocation.Length)); var destDir = Path.GetDirectoryName(dest); if (!Directory.Exists(destDir)) { logger.Info("Creating directory " + destDir); Directory.CreateDirectory(destDir); } File.Copy(file, dest, true); } catch (Exception e) { logger.Error(e); } } // delete old dirs string[] oldDirs = new string[] { "Content/logos" }; foreach (var oldDir in oldDirs) { try { var deleteDir = Path.Combine(options.Path, oldDir); if (Directory.Exists(deleteDir)) { logger.Info("Deleting directory " + deleteDir); Directory.Delete(deleteDir, true); } } catch (Exception e) { logger.Error(e); } } // delete old files string[] oldFiles = new string[] { "Content/css/jquery.dataTables.css", "Content/css/jquery.dataTables_themeroller.css", "Definitions/tspate.yml", "Definitions/freakstrackingsystem.yml", "Definitions/rarbg.yml", "Definitions/t411.yml", "Definitions/hdbc.yml", // renamed to hdbitscom "Definitions/maniatorrent.yml", "Definitions/nyaa.yml", "Definitions/nachtwerk.yml", "Definitions/leparadisdunet.yml", "Definitions/qctorrent.yml", "Definitions/dragonworld.yml", "Definitions/hdclub.yml", "Definitions/polishtracker.yml", "Definitions/zetorrents.yml", "Definitions/rapidetracker.yml", "Definitions/isohunt.yml", "Definitions/t411v2.yml", "Definitions/bithq.yml", "Definitions/blubits.yml", "Definitions/torrentproject.yml", "Definitions/torrentvault.yml", "Definitions/apollo.yml", // migrated to C# gazelle base tracker "Definitions/secretcinema.yml", // migrated to C# gazelle base tracker "Definitions/utorrents.yml", // same as SzeneFZ now "Definitions/ultrahdclub.yml", "Definitions/infinityt.yml", "Definitions/hachede-c.yml", "Definitions/skytorrents.yml", "Definitions/gormogon.yml", "Definitions/czteam.yml", "Definitions/rockhardlossless.yml", "Definitions/oxtorrent.yml", "Definitions/tehconnection.yml", "Definitions/torrentwtf.yml", "Definitions/eotforum.yml", "Definitions/nexttorrent.yml", "Definitions/torrentsmd.yml", "Definitions/scenehd.yml", // migrated to C# (use JSON API) "appsettings.Development.json", "CurlSharp.dll", "CurlSharp.pdb", "Autofac.Integration.WebApi.dll", "Microsoft.Owin.dll", "Microsoft.Owin.FileSystems.dll", "Microsoft.Owin.Host.HttpListener.dll", "Microsoft.Owin.Hosting.dll", "Microsoft.Owin.StaticFiles.dll", "Owin.dll", "System.Web.Http.dll", "System.Web.Http.Owin.dll", "System.Web.Http.Tracing.dll", "Definitions/torrentkim.yml", "Definitions/horriblesubs.yml", "Definitions/idope.yml", "Definitions/bt-scene.yml", "Definitions/extratorrentclone.yml", "Definitions/torrentcouch.yml", "Definitions/idopeclone.yml", "Definitions/torrof.yml", "Definitions/archetorrent.yml", "Definitions/420files.yml", "Definitions/redtopia.yml", "Definitions/btxpress.yml", "Definitions/btstornet.yml", "Definitions/crazyhd.yml", "Definitions/hdplus.yml", "Definitions/gods.yml", }; foreach (var oldFile in oldFiles) { try { var deleteFile = Path.Combine(options.Path, oldFile); if (File.Exists(deleteFile)) { logger.Info("Deleting file " + deleteFile); File.Delete(deleteFile); } } catch (Exception e) { logger.Error(e); } } // kill pids after the update on UNIX if (!isWindows) { KillPids(pids); } if (!options.NoRestart) { if (isWindows && (trayRunning || options.StartTray) && !string.Equals(options.Type, "WindowsService", StringComparison.OrdinalIgnoreCase)) { var startInfo = new ProcessStartInfo() { Arguments = $"--UpdatedVersion \" {EnvironmentUtil.JackettVersion}\"", FileName = Path.Combine(options.Path, "JackettTray.exe"), UseShellExecute = true }; logger.Info("Starting Tray: " + startInfo.FileName + " " + startInfo.Arguments); 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, "WindowsService", StringComparison.OrdinalIgnoreCase)) { logger.Info("Starting Windows service"); if (ServerUtil.IsUserAdministrator()) { windowsService.Start(); } else { try { var consolePath = Path.Combine(options.Path, "JackettConsole.exe"); processService.StartProcessAndLog(consolePath, "--Start", true); } catch { logger.Error("Failed to get admin rights to start the service."); } } } else { var startInfo = new ProcessStartInfo() { Arguments = options.Args, FileName = GetJackettConsolePath(options.Path), UseShellExecute = true }; if (isWindows) { //User didn't initiate the update from Windows service and wasn't running Jackett via the tray, must have started from the console startInfo.Arguments = $"/K {startInfo.FileName} {startInfo.Arguments}"; startInfo.FileName = "cmd.exe"; startInfo.CreateNoWindow = false; startInfo.WindowStyle = ProcessWindowStyle.Normal; } if (variant == Variants.JackettVariant.Mono) { startInfo.Arguments = startInfo.FileName + " " + startInfo.Arguments; startInfo.FileName = "mono"; } if (variant == Variants.JackettVariant.CoreMacOs || variant == Variants.JackettVariant.CoreLinuxAmdx64 || variant == Variants.JackettVariant.CoreLinuxArm32 || variant == Variants.JackettVariant.CoreLinuxArm64) { startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true; } logger.Info("Starting Jackett: " + startInfo.FileName + " " + startInfo.Arguments); Process.Start(startInfo); } } }
public void CanNullAndEmpty() { Assert.Empty(Variants.Expand(null)); Assert.Empty(Variants.Expand(string.Empty)); }
public void AddVariant(Class c) { Variants.Add(c); }
public Move DoMove() { Variant = (Variants)new Random().Next(0, 5); Thread.Sleep(10); return this; }
public UpdateVehicle(Guid vehicleId, string description, decimal pricePerService, Variants variants) { VehicleId = vehicleId; Description = description; PricePerService = pricePerService; Variants = variants; }