Private GIT

Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching

SickBeard.py

Blame
  • UpdateService.cs 10.71 KiB
    using ICSharpCode.SharpZipLib.GZip;
    using ICSharpCode.SharpZipLib.Tar;
    using ICSharpCode.SharpZipLib.Zip;
    using Jackett.Models.GitHub;
    using Jackett.Utils.Clients;
    using Newtonsoft.Json;
    using NLog;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.IO;
    using System.Linq;
    using System.Net.Security;
    using System.Reflection;
    using System.Security.Cryptography.X509Certificates;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using Jackett.Services.Interfaces;
    using Jacket.Common;
    using Jackett.Models.Config;
    
    namespace Jackett.Services
    {
    
        public class UpdateService: IUpdateService
        {
            Logger logger;
            WebClient client;
            IConfigurationService configService;
            ManualResetEvent locker = new ManualResetEvent(false);
            ITrayLockService lockService;
            bool forceupdatecheck = false;
    
            public UpdateService(Logger l, WebClient c, IConfigurationService cfg, ITrayLockService ls)
            {
                logger = l;
                client = c;
                configService = cfg;
                lockService = ls;
            }
    
            private string ExePath()
            {
                var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase);
                return new FileInfo(location.AbsolutePath).FullName;
            }
    
            public void StartUpdateChecker()
            {
                Task.Factory.StartNew(UpdateWorkerThread);
            }
    
            public void CheckForUpdatesNow()
            {
                forceupdatecheck = true;
                locker.Set();
            }
    
            private async void UpdateWorkerThread()
            {
                while (true)
                {
                    locker.WaitOne((int)new TimeSpan(24, 0, 0).TotalMilliseconds);
                    locker.Reset();
                    await CheckForUpdates();
                }
            }
    
            private bool AcceptCert(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)