Example #1
0
        public bool ApplyUpdate()
        {
            try
            {
                Console.WriteLine("IRSE:  Applying Update...");

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

                // for all of the files already in the server folder
                foreach (var file in CurrentFileList)
                {
                    // if the old file has an updated version
                    if (FileList.Exists(x => x.Name == file.Name))
                    {
                        var newFile  = FileList.Find(x => x.Name == file.Name);
                        var fullName = Path.GetFullPath(file.FullName);

                        // rename old file if the file exists
                        if (File.Exists(fullName))
                        {
                            File.Move(fullName, fullName + ".old");
                        }

                        // move new file if it doesn't already exist
                        if (!File.Exists(fullName) && File.Exists(Path.GetFullPath(newFile.FullName)))
                        {
                            File.Move(Path.GetFullPath(newFile.FullName), fullName);
                        }
                    }
                }

                if (EnableAutoRestarts)
                {
                    Program.Restart();
                }

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

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("IRSE:  Update Failed (ApplyUpdate)" + ex.ToString());
            }
            return(false);
        }
        public bool ApplyUpdate()
        {
            try
            {
                Console.WriteLine("HellionExtendedServer:  Applying Update...");

                string updatePath = Globals.GetFolderPath(HESFolderName.Updates);
                string hesPath    = Globals.GetFolderPath(HESFolderName.Hes);

                // for all of the files already in the server folder
                foreach (var file in CurrentFileList)
                {
                    // if the old file has an updated version
                    if (FileList.Exists(x => x.Name == file.Name))
                    {
                        var newFile  = FileList.Find(x => x.Name == file.Name);
                        var fullName = Path.GetFullPath(file.FullName);

                        // rename old file if the file exists
                        if (File.Exists(fullName))
                        {
                            File.Move(fullName, fullName + ".old");
                        }

                        // move new file if it doesn't already exist
                        if (!File.Exists(fullName) && File.Exists(Path.GetFullPath(newFile.FullName)))
                        {
                            File.Move(Path.GetFullPath(newFile.FullName), fullName);
                        }
                    }
                }

                if (Config.Instance.Settings.AutoRestartsEnable && !GUIMode)
                {
                    HES.Restart();
                }

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

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("HellionExtendedServer:  Update Failed (ApplyUpdate)" + ex.ToString());
            }
            return(false);
        }