Esempio n. 1
0
        public void HandleRequest(HttpListenerContext context)
        {
            var req  = context.Request;
            var resp = context.Response;

            try
            {
                var ss = new StartupStatus();
                ss.UpgradeRestoreAvailable = false;
                if (_mod.IsBeatSaberInstalled && _mod.IsInstalledBeatSaberModded)
                {
                    var qaeConfig = _getQaeConfig();
                    if (qaeConfig.RootFileProvider.FileExists(Constants.LAST_COMMITTED_CONFIG))
                    {
                        var si    = _getSyncInfo();
                        var bsVer = _mod.GetBeatSaberVersion();
                        if (si?.LastSyncedBeatSaberVersion != bsVer)
                        {
                            var qae = _getQae();
                            if (!qae.OpManager.IsProcessing)
                            {
                                ss.UpgradeRestoreAvailable = true;
                            }
                        }
                    }
                }
                resp.SerializeOk(ss);
            }
            catch (Exception ex)
            {
                Log.LogErr("Exception handling mod status!", ex);
                resp.StatusCode = 500;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Saves the current committed config to disk.  Returns false if the current config isn't committed
        /// </summary>
        private bool SaveCommittedConfigToDisk()
        {
            RolloverConfigBackups();
            //todo: this is SO the wrong place for this.  Suppose I'll move it after I put it here for testing.  probably should save instantly on update and not be part of sync
            SyncManager.Save();


            if (!CurrentConfig.IsCommitted || Engine.HasChanges)
            {
                return(false);
            }
            lock (_configFileLock)
            {
                _mod.BackupPlayerData(onlyIfNewer: true, onlyIfBigger: true);
                try
                {
                    try
                    {
                        SyncInfo si = new SyncInfo()
                        {
                            LastSyncDateTime           = DateTime.Now,
                            LastSyncedBeatOnVersion    = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                            LastSyncedBeatSaberVersion = _mod.GetBeatSaberVersion()
                        };
                        var siString = JsonConvert.SerializeObject(si);
                        _qaeConfig.RootFileProvider.Write(Constants.SYNC_INFO, System.Text.Encoding.UTF8.GetBytes(siString), true);
                    }
                    catch (Exception ex)
                    {
                        Log.LogErr($"Exception trying to save last sync version info.");
                    }
                    var configString = JsonConvert.SerializeObject(CurrentConfig.Config);
                    _qaeConfig.RootFileProvider.Write(Constants.LAST_COMMITTED_CONFIG, System.Text.Encoding.UTF8.GetBytes(configString), true);
                    return(true);
                }
                catch (Exception ex)
                {
                    Log.LogErr($"Exception saving committed config to disk.", ex);
                    return(false);
                }
            }
        }