Async downloader, better Proton support (#183)
* feat: async downloader + other fixes * feat: windows command parsing + use library path for install path * feat: better proton support * feat: style fixes and store button now uses in-app * feat: emulator rename + umu emulator fix * feat: bring process creation inline with docs * fix: clippy
This commit is contained in:
@@ -4,10 +4,8 @@ use std::{
|
||||
time::{Duration, SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use chrono::Utc;
|
||||
use client::{app_status::AppStatus, user::User};
|
||||
use database::{DatabaseAuth, interface::borrow_db_checked};
|
||||
use droplet_rs::ssl::sign_nonce;
|
||||
use gethostname::gethostname;
|
||||
use jsonwebtoken::{Algorithm, EncodingKey, Header};
|
||||
use log::{error, warn};
|
||||
|
||||
@@ -35,6 +35,7 @@ pub enum RemoteAccessError {
|
||||
Cache(std::io::Error),
|
||||
CorruptedState,
|
||||
NoDepots,
|
||||
FailedDownload,
|
||||
}
|
||||
|
||||
impl Display for RemoteAccessError {
|
||||
@@ -104,8 +105,12 @@ impl Display for RemoteAccessError {
|
||||
f,
|
||||
"Drop encountered a corrupted internal state. Please report this to the developers, with details of reproduction."
|
||||
),
|
||||
RemoteAccessError::NoDepots => write!(f, "There are no download depots configured on the server. Contact your server admin."),
|
||||
}
|
||||
RemoteAccessError::NoDepots => write!(
|
||||
f,
|
||||
"There are no download depots configured on the server. Contact your server admin."
|
||||
),
|
||||
RemoteAccessError::FailedDownload => write!(f, "Failed to download."),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,21 +44,33 @@ impl Middleware for AutoOfflineMiddleware {
|
||||
extensions: &mut Extensions,
|
||||
next: Next<'_>,
|
||||
) -> Result<Response> {
|
||||
let url = req.url().clone();
|
||||
let res = next.run(req, extensions).await;
|
||||
match res {
|
||||
Ok(res) => {
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let lock = DROP_APP_HANDLE.lock().await;
|
||||
if let Some(app_handle) = &*lock {
|
||||
let state = app_handle.state::<std::sync::nonpoison::Mutex<AppState>>();
|
||||
let mut state_lock = state.lock();
|
||||
if state_lock.status == AppStatus::Offline {
|
||||
state_lock.status = AppStatus::SignedIn;
|
||||
app_handle
|
||||
.emit("update_state", &*state_lock)
|
||||
.expect("failed to emit state update");
|
||||
}
|
||||
};
|
||||
let lock = DROP_APP_HANDLE.try_lock();
|
||||
if let Ok(lock) = lock {
|
||||
if let Some(app_handle) = &*lock {
|
||||
let state = app_handle.state::<std::sync::nonpoison::Mutex<AppState>>();
|
||||
let state_lock = state.try_lock();
|
||||
if let Ok(mut state_lock) = state_lock {
|
||||
if state_lock.status == AppStatus::Offline {
|
||||
state_lock.status = AppStatus::SignedIn;
|
||||
app_handle
|
||||
.emit("update_state", &*state_lock)
|
||||
.expect("failed to emit state update");
|
||||
}
|
||||
} else {
|
||||
warn!("failed to lock app state - {}", url.as_str());
|
||||
}
|
||||
};
|
||||
} else {
|
||||
warn!(
|
||||
"failed to lock app handle for offline/online middleware - {}",
|
||||
url.as_str()
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Ok(res)
|
||||
|
||||
Reference in New Issue
Block a user