private void ReleaseDownloaded(object sender, DownloadDataCompletedEventArgs e)
        {
            try
            {
                FileList.ForEach((file) => file.Delete());
                FileList.Clear();

                string updatePath = ExtenderGlobals.GetFolderPath(IRSEFolderName.Updates);

                File.WriteAllBytes(Path.Combine(updatePath, UpdateFileName), e.Result);
                ZipFile.ExtractToDirectory(Path.Combine(updatePath, UpdateFileName), updatePath);
                File.Delete(Path.Combine(updatePath, UpdateFileName));
                Console.WriteLine("IRSE:  Update has been downloaded!");

                foreach (string file in Directory.GetFiles(updatePath, "*", SearchOption.AllDirectories))
                {
                    FileList.Add(new FileInfo(file));
                }

                OnUpdateDownloaded?.Invoke(m_useDevRelease ? m_developmentRelease : m_currentRelease);

                if (!GUIMode)
                {
                    ApplyUpdate();
                    Console.WriteLine("IRSE:  Update has been applied. Please restart IRSE.exe to finish the update!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("IRSE:  Update Failed (ReleaseDownloadedEvent)" + ex.ToString());
            }
        }
Esempio n. 2
0
        private void ReleaseDownloaded(object sender, DownloadDataCompletedEventArgs e)
        {
            try
            {
                FileList.ForEach((file) => file.Delete());
                FileList.Clear();

                string updatePath = ExtenderGlobals.GetFolderPath(IRSEFolderName.Updates);

                File.WriteAllBytes(Path.Combine(updatePath, UpdateFileName), e.Result);
                ZipFile.ExtractToDirectory(Path.Combine(updatePath, UpdateFileName), updatePath);
                File.Delete(Path.Combine(updatePath, UpdateFileName));
                Console.WriteLine("IRSE:  Update has been downloaded!");

                foreach (string file in Directory.GetFiles(updatePath, "*", SearchOption.AllDirectories))
                {
                    FileList.Add(new FileInfo(file));
                }

                OnUpdateDownloaded?.Invoke(m_useDevRelease ? DevelopmentRelease : CurrentRelease);

                if (!GUIMode)
                {
                    ApplyUpdate();
                    Console.WriteLine("IRSE:  Update has been applied.");

                    if (Config.Instance.Settings.AutoRestartsEnable)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("IRSE:  Auto-Restarts enabled. Restarting...");
                        Program.Restart();
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("IRSE:  Press Y to restart IRSE. or N if you want to restart later.");
                        Console.ResetColor();

                        switch (Console.ReadKey().Key)
                        {
                        case ConsoleKey.Y:
                            Program.Restart();
                            break;

                        case ConsoleKey.N:
                            break;

                        default:
                            break;
                        }
                    }
                }

                UpdaterDone = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("IRSE:  Update Failed (ReleaseDownloadedEvent)" + ex.ToString());
            }
        }