Updating + Profile Repairs + Performance Improvements (#97)

* repairing

* Main framework for updating

* add jsconfig

* more work

* Improve performance

* Finish updating

* run lint
This commit is contained in:
Geometrically
2023-04-26 10:28:08 -07:00
committed by GitHub
parent c53104c28e
commit f0b8a708a3
48 changed files with 1217 additions and 894 deletions

View File

@@ -1,4 +1,5 @@
//! Theseus settings file
use crate::{jre, State};
use serde::{Deserialize, Serialize};
use std::path::Path;
use tokio::fs;
@@ -63,6 +64,29 @@ impl Settings {
}
}
pub async fn update_java() {
let res = async {
let state = State::get().await?;
let settings_read = state.settings.write().await;
if settings_read.java_globals.count() == 0 {
drop(settings_read);
let java_globals = jre::autodetect_java_globals().await?;
state.settings.write().await.java_globals = java_globals;
}
Ok::<(), crate::Error>(())
}
.await;
match res {
Ok(()) => {}
Err(err) => {
log::warn!("Unable to update launcher java: {err}")
}
};
}
#[tracing::instrument(skip(self))]
pub async fn sync(&self, to: &Path) -> crate::Result<()> {
fs::write(to, serde_json::to_vec(self)?)