Exemple #1
0
 internal void OnUserRequestUpdater(Client client, string remoteHash)
 {
     if (Directory.Exists(selfUpdatesDir))
     {
         if (File.Exists(updaterPath))
         {
             string hash = Hash.GetSHA512Hash(updaterPath);
             if (hash != remoteHash || remoteHash == "NO_HASH")
             {
                 string zipName = compressFile(updaterPath);
                 ClientPackets.Instance.SC_SendSelfUpdater(client, zipName);
             }
         }
     }
 }
Exemple #2
0
        public void OnUserRequestSelfUpdateRequired(Client client, string remoteHash)
        {
            bool result = false;

            if (Directory.Exists(selfUpdatesDir))
            {
                if (File.Exists(selfUpdatePath))
                {
                    string hash = Hash.GetSHA512Hash(selfUpdatePath);
                    result = hash != remoteHash;
                }
            }

            ClientPackets.Instance.SC_SendSelfUpdateRequired(client, result);
        }
Exemple #3
0
        public void OnUserRequestSelfUpdate(Client client, string remoteHash)
        {
            if (Directory.Exists(selfUpdatesDir))
            {
                if (File.Exists(selfUpdatePath))
                {
                    string hash = Hash.GetSHA512Hash(selfUpdatePath);
                    if (hash != remoteHash)
                    {
                        string zipName = compressFile(selfUpdatePath);

                        ClientPackets.Instance.SC_SendSelfUpdate(client, zipName);
                    }
                }
            }
        }
Exemple #4
0
        public void LoadUpdateList()
        {
            switch (OPT.GetInt("send.type"))
            {
            case 0:     // Google drive
                using (StreamReader sr = new StreamReader(File.Open(string.Format(@"{0}\{1}", Directory.GetCurrentDirectory(), "gIndex.opt"), FileMode.Open, FileAccess.Read)))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] optBlocks = line.Split('|');
                        if (optBlocks.Length == 4)
                        {
                            UpdateIndex.Add(new IndexEntry {
                                FileName = optBlocks[0], SHA512 = optBlocks[1], Legacy = Convert.ToBoolean(Convert.ToInt32(optBlocks[2])), Delete = Convert.ToBoolean(Convert.ToInt32(optBlocks[3]))
                            });
                        }
                    }
                }
                break;

            case 1:     // HTTP
                break;

            case 2:     // FTP
                break;

            case 3:     // TCP
                foreach (string filePath in Directory.GetFiles(updatesDir))
                {
                    string fileName = Path.GetFileName(filePath);

                    UpdateIndex.Add(new IndexEntry
                    {
                        FileName = fileName,
                        SHA512   = Hash.GetSHA512Hash(filePath),
                        Legacy   = OPT.IsLegacy(fileName),
                        Delete   = OPT.IsDelete(fileName)
                    });
                }
                break;
            }
        }
Exemple #5
0
        public static void Build(bool rebuild)
        {
            if (rebuild && OPT.GetBool("debug"))
            {
                Console.Write("Rebuilding the Update Index...");
            }
            else
            {
                Console.Write("Building the Update Index...");
            }

            Program.Wait = true;

            if (Index.Count > 0)
            {
                Index.Clear();
            }

            switch (OPT.GetInt("send.type"))
            {
            case 0:     // Google drive
                using (StreamReader sr = new StreamReader(File.Open(string.Format(@"{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "gIndex.opt"), FileMode.Open, FileAccess.Read)))
                {
                    //string line;
                    //while ((line = sr.ReadLine()) != null)
                    //{
                    //    string[] optBlocks = line.Split('|');
                    //    if (optBlocks.Length == 4)
                    //    {
                    //        Index.Add(new IndexEntry { FileName = optBlocks[0], SHA512 = optBlocks[1], Legacy = Convert.ToBoolean(Convert.ToInt32(optBlocks[2])), Delete = Convert.ToBoolean(Convert.ToInt32(optBlocks[3])) });
                    //    }
                    //}
                }
                break;

            case 1:     // HTTP
                break;

            case 2:     // FTP
                break;

            case 3:     // TCP
                foreach (string filePath in System.IO.Directory.GetFiles(UpdatesDirectory))
                {
                    string fileName = Path.GetFileName(filePath);

                    Index.Add(new IndexEntry
                    {
                        FileName = fileName,
                        SHA512   = Hash.GetSHA512Hash(filePath),
                        Legacy   = OPT.IsLegacy(fileName),
                        Delete   = OPT.IsDelete(fileName)
                    });
                }
                break;
            }

            if (rebuild && OPT.GetBool("debug"))
            {
                Console.WriteLine("[OK]\n\t{0} files indexed", Count);
            }
            else
            {
                Console.WriteLine("[OK]\n\t{0} files indexed", Count);
            }

            Program.Wait = false;
        }
Exemple #6
0
        public static void Build(bool rebuild)
        {
            Output.WriteAndLock(new Message()
            {
                Text = string.Format("{0} the Update Index...", (rebuild && OPT.GetBool("debug")) ? "Rebuilding" : "Building")
            });

            if (rebuild)
            {
                Program.Wait = true;
            }

            if (Index.Count > 0)
            {
                Index.Clear();
            }

            switch (OPT.GetInt("send.type"))
            {
            case 0:     // Google drive
                using (StreamReader sr = new StreamReader(File.Open(string.Format(@"{0}\{1}", System.IO.Directory.GetCurrentDirectory(), "gIndex.opt"), FileMode.Open, FileAccess.Read)))
                {
                    //string line;
                    //while ((line = sr.ReadLine()) != null)
                    //{
                    //    string[] optBlocks = line.Split('|');
                    //    if (optBlocks.Length == 4)
                    //    {
                    //        Index.Add(new IndexEntry { FileName = optBlocks[0], SHA512 = optBlocks[1], Legacy = Convert.ToBoolean(Convert.ToInt32(optBlocks[2])), Delete = Convert.ToBoolean(Convert.ToInt32(optBlocks[3])) });
                    //    }
                    //}
                }
                break;

            case 1:     // HTTP
                break;

            case 2:     // FTP
                break;

            case 3:     // TCP
                foreach (string filePath in System.IO.Directory.GetFiles(UpdatesDirectory))
                {
                    string fileName = Path.GetFileName(filePath);

                    Index.Add(new IndexEntry
                    {
                        FileName = fileName,
                        SHA512   = Hash.GetSHA512Hash(filePath),
                        Legacy   = OPT.IsLegacy(fileName),
                        Delete   = OPT.IsDelete(fileName)
                    });
                }
                break;
            }

            if (OPT.GetBool("debug"))
            {
                Output.WriteAndUnlock(new Message()
                {
                    Text = string.Format("[OK]\n\t- {0} files indexed", Count), AddBreak = true
                });
            }

            if (rebuild)
            {
                Program.Wait = false;
            }

            GUI.Instance.Invoke(new System.Windows.Forms.MethodInvoker(delegate {
                GUI.Instance.updatesViewBtn.Enabled = true;
                GUI.Instance.updatesView.Enabled    = true;
            }));
        }