/// <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); } } }
public void BackupPlayerData() { _mod?.BackupPlayerData(true, true); }