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

@@ -66,7 +66,7 @@ pub async fn init_loading_unsafe(
let event_state = crate::EventState::get().await?;
let key = LoadingBarId(Uuid::new_v4());
event_state.loading_bars.write().await.insert(
event_state.loading_bars.insert(
key.0,
LoadingBar {
loading_bar_uuid: key.0,
@@ -121,7 +121,7 @@ pub async fn edit_loading(
) -> crate::Result<()> {
let event_state = crate::EventState::get().await?;
if let Some(bar) = event_state.loading_bars.write().await.get_mut(&id.0) {
if let Some(mut bar) = event_state.loading_bars.get_mut(&id.0) {
bar.bar_type = bar_type;
bar.total = total;
bar.message = title.to_string();
@@ -152,8 +152,7 @@ pub async fn emit_loading(
) -> crate::Result<()> {
let event_state = crate::EventState::get().await?;
let mut loading_bar = event_state.loading_bars.write().await;
let loading_bar = match loading_bar.get_mut(&key.0) {
let mut loading_bar = match event_state.loading_bars.get_mut(&key.0) {
Some(f) => f,
None => {
return Err(EventError::NoLoadingBar(key.0).into());
@@ -250,7 +249,7 @@ pub async fn emit_command(command: CommandPayload) -> crate::Result<()> {
#[allow(unused_variables)]
pub async fn emit_process(
profile_path: &str,
pid: u32,
uuid: Uuid,
event: ProcessPayloadType,
message: &str,
) -> crate::Result<()> {
@@ -263,7 +262,7 @@ pub async fn emit_process(
"process",
ProcessPayload {
profile_path_id: profile_path.to_string(),
pid,
uuid,
event,
message: message.to_string(),
},

View File

@@ -1,8 +1,8 @@
//! Theseus state management system
use dashmap::DashMap;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, path::PathBuf, sync::Arc};
use std::{path::PathBuf, sync::Arc};
use tokio::sync::OnceCell;
use tokio::sync::RwLock;
use uuid::Uuid;
pub mod emit;
@@ -14,7 +14,7 @@ pub struct EventState {
/// Tauri app
#[cfg(feature = "tauri")]
pub app: tauri::AppHandle,
pub loading_bars: RwLock<HashMap<Uuid, LoadingBar>>,
pub loading_bars: DashMap<Uuid, LoadingBar>,
}
impl EventState {
@@ -24,7 +24,7 @@ impl EventState {
.get_or_try_init(|| async {
Ok(Arc::new(Self {
app,
loading_bars: RwLock::new(HashMap::new()),
loading_bars: DashMap::new(),
}))
})
.await
@@ -36,7 +36,7 @@ impl EventState {
EVENT_STATE
.get_or_try_init(|| async {
Ok(Arc::new(Self {
loading_bars: RwLock::new(HashMap::new()),
loading_bars: DashMap::new(),
}))
})
.await
@@ -55,17 +55,10 @@ impl EventState {
}
// Values provided should not be used directly, as they are clones and are not guaranteed to be up-to-date
pub async fn list_progress_bars() -> crate::Result<HashMap<Uuid, LoadingBar>>
pub async fn list_progress_bars() -> crate::Result<DashMap<Uuid, LoadingBar>>
{
let value = Self::get().await?;
let read = value.loading_bars.read().await;
let mut display_list: HashMap<Uuid, LoadingBar> = HashMap::new();
for (uuid, loading_bar) in read.iter() {
display_list.insert(*uuid, loading_bar.clone());
}
Ok(display_list)
Ok(value.loading_bars.clone())
}
#[cfg(feature = "tauri")]
@@ -100,10 +93,10 @@ impl Drop for LoadingBarId {
let loader_uuid = self.0;
tokio::spawn(async move {
if let Ok(event_state) = EventState::get().await {
let mut bars = event_state.loading_bars.write().await;
#[cfg(any(feature = "tauri", feature = "cli"))]
if let Some(bar) = bars.remove(&loader_uuid) {
if let Some((_, bar)) =
event_state.loading_bars.remove(&loader_uuid)
{
#[cfg(feature = "tauri")]
{
let loader_uuid = bar.loading_bar_uuid;
@@ -135,7 +128,7 @@ impl Drop for LoadingBarId {
}
#[cfg(not(any(feature = "tauri", feature = "cli")))]
bars.remove(&loader_uuid);
event_state.loading_bars.remove(&loader_uuid);
}
});
}
@@ -145,7 +138,11 @@ impl Drop for LoadingBarId {
#[serde(tag = "type")]
#[serde(rename_all = "snake_case")]
pub enum LoadingBarType {
StateInit,
LegacyDataMigration,
DirectoryMove {
old: PathBuf,
new: PathBuf,
},
JavaDownload {
version: u32,
},
@@ -222,7 +219,7 @@ pub enum CommandPayload {
#[derive(Serialize, Clone)]
pub struct ProcessPayload {
pub profile_path_id: String,
pub pid: u32,
pub uuid: Uuid,
pub event: ProcessPayloadType,
pub message: String,
}