0.8.0 beta fixes (#2154)

* initial fixes

* 0.8.0 beta fixes

* run actions

* run fmt

* Fix windows build

* Add purge cache opt

* add must revalidate to project req

* lint + clippy

* fix processes, open folder

* Update migrator to use old launcher cache for perf

* fix empty dirs not moving

* fix lint + create natives dir if not exist

* fix large request batches

* finish

* Fix deep linking on mac

* fix comp err

* fix comp err (2)

---------

Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
Geometrically
2024-08-16 23:20:11 -07:00
committed by GitHub
parent 3a4843fb46
commit 910e219c0e
66 changed files with 1961 additions and 1896 deletions

View File

@@ -1,8 +1,4 @@
//! Theseus state management system
use crate::event::emit::{emit_loading, init_loading_unsafe};
use crate::event::LoadingBarType;
use crate::util::fetch::{FetchSemaphore, IoSemaphore};
use std::sync::Arc;
use tokio::sync::{OnceCell, Semaphore};
@@ -35,7 +31,7 @@ pub use self::minecraft_auth::*;
mod cache;
pub use self::cache::*;
mod db;
pub mod db;
pub mod fs_watcher;
mod mr_auth;
@@ -61,6 +57,9 @@ pub struct State {
/// Discord RPC
pub discord_rpc: DiscordGuard,
/// Process manager
pub process_manager: ProcessManager,
pub(crate) pool: SqlitePool,
pub(crate) file_watcher: FileWatcher,
@@ -72,7 +71,13 @@ impl State {
.get_or_try_init(Self::initialize_state)
.await?;
Process::garbage_collect(&state.pool).await?;
tokio::task::spawn(async move {
let res = state.discord_rpc.clear_to_default(true).await;
if let Err(e) = res {
tracing::error!("Error running discord RPC: {e}");
}
});
Ok(())
}
@@ -94,13 +99,6 @@ impl State {
#[tracing::instrument]
async fn initialize_state() -> crate::Result<Arc<Self>> {
let loading_bar = init_loading_unsafe(
LoadingBarType::StateInit,
100.0,
"Initializing launcher",
)
.await?;
let pool = db::connect().await?;
legacy_converter::migrate_legacy_data(&pool).await?;
@@ -120,29 +118,20 @@ impl State {
&io_semaphore,
)
.await?;
let directories = DirectoryInfo::init(settings.custom_dir).await?;
emit_loading(&loading_bar, 10.0, None).await?;
let discord_rpc = DiscordGuard::init().await?;
if settings.discord_rpc {
// Add default Idling to discord rich presence
// Force add to avoid recursion
let _ = discord_rpc.force_set_activity("Idling...", true).await;
}
let discord_rpc = DiscordGuard::init()?;
let file_watcher = fs_watcher::init_watcher().await?;
fs_watcher::watch_profiles_init(&file_watcher, &directories).await?;
emit_loading(&loading_bar, 10.0, None).await?;
Ok(Arc::new(Self {
directories,
fetch_semaphore,
io_semaphore,
api_semaphore,
discord_rpc,
process_manager: ProcessManager::new(),
pool,
file_watcher,
}))