mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-14 00:31:33 +10:00
chore: Run clippy fix pedantic
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@ -1,3 +1,3 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
tauri_build::build()
|
tauri_build::build();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,8 +13,8 @@ pub fn cleanup_and_exit(app: &AppHandle, state: &tauri::State<'_, std::sync::Mut
|
|||||||
let download_manager = state.lock().unwrap().download_manager.clone();
|
let download_manager = state.lock().unwrap().download_manager.clone();
|
||||||
match download_manager.ensure_terminated() {
|
match download_manager.ensure_terminated() {
|
||||||
Ok(res) => match res {
|
Ok(res) => match res {
|
||||||
Ok(_) => debug!("download manager terminated correctly"),
|
Ok(()) => debug!("download manager terminated correctly"),
|
||||||
Err(_) => error!("download manager failed to terminate correctly"),
|
Err(()) => error!("download manager failed to terminate correctly"),
|
||||||
},
|
},
|
||||||
Err(e) => panic!("{e:?}"),
|
Err(e) => panic!("{e:?}"),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,20 +67,17 @@ impl DatabaseImpls for DatabaseInterface {
|
|||||||
|
|
||||||
let exists = fs::exists(db_path.clone()).unwrap();
|
let exists = fs::exists(db_path.clone()).unwrap();
|
||||||
|
|
||||||
match exists {
|
if exists { match PathDatabase::load_from_path(db_path.clone()) {
|
||||||
true => match PathDatabase::load_from_path(db_path.clone()) {
|
Ok(db) => db,
|
||||||
Ok(db) => db,
|
Err(e) => handle_invalid_database(e, db_path, games_base_dir, cache_dir),
|
||||||
Err(e) => handle_invalid_database(e, db_path, games_base_dir, cache_dir),
|
} } else {
|
||||||
},
|
let default = Database::new(games_base_dir, None, cache_dir);
|
||||||
false => {
|
debug!(
|
||||||
let default = Database::new(games_base_dir, None, cache_dir);
|
"Creating database at path {}",
|
||||||
debug!(
|
db_path.as_os_str().to_str().unwrap()
|
||||||
"Creating database at path {}",
|
);
|
||||||
db_path.as_os_str().to_str().unwrap()
|
PathDatabase::create_at_path(db_path, default)
|
||||||
);
|
.expect("Database could not be created")
|
||||||
PathDatabase::create_at_path(db_path, default)
|
|
||||||
.expect("Database could not be created")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,19 +134,19 @@ impl<'a> Deref for DBRead<'a> {
|
|||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> DerefMut for DBWrite<'a> {
|
impl DerefMut for DBWrite<'_> {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> Drop for DBWrite<'a> {
|
impl Drop for DBWrite<'_> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ManuallyDrop::drop(&mut self.0);
|
ManuallyDrop::drop(&mut self.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
match DB.save() {
|
match DB.save() {
|
||||||
Ok(_) => {}
|
Ok(()) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("database failed to save with error {e}");
|
error!("database failed to save with error {e}");
|
||||||
panic!("database failed to save with error {e}")
|
panic!("database failed to save with error {e}")
|
||||||
|
|||||||
@ -27,7 +27,7 @@ pub mod data {
|
|||||||
use serde_with::serde_as;
|
use serde_with::serde_as;
|
||||||
use std::{collections::HashMap, path::PathBuf};
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
|
||||||
use super::*;
|
use super::{Serialize, Deserialize, native_model};
|
||||||
|
|
||||||
fn default_template() -> String {
|
fn default_template() -> String {
|
||||||
"{}".to_owned()
|
"{}".to_owned()
|
||||||
@ -174,7 +174,7 @@ pub mod data {
|
|||||||
|
|
||||||
use serde_with::serde_as;
|
use serde_with::serde_as;
|
||||||
|
|
||||||
use super::*;
|
use super::{Serialize, Deserialize, native_model, Settings, DatabaseAuth, v1, GameVersion, DownloadableMetadata, ApplicationTransientStatus};
|
||||||
|
|
||||||
#[native_model(id = 1, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)]
|
#[native_model(id = 1, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||||
@ -283,7 +283,7 @@ pub mod data {
|
|||||||
mod v3 {
|
mod v3 {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use super::*;
|
use super::{Serialize, Deserialize, native_model, Settings, DatabaseAuth, DatabaseApplications, DatabaseCompatInfo, v2};
|
||||||
#[native_model(id = 1, version = 3, with = native_model::rmp_serde_1_3::RmpSerde)]
|
#[native_model(id = 1, version = 3, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||||
pub struct Database {
|
pub struct Database {
|
||||||
@ -336,7 +336,7 @@ pub mod data {
|
|||||||
transient_statuses: HashMap::new(),
|
transient_statuses: HashMap::new(),
|
||||||
},
|
},
|
||||||
prev_database,
|
prev_database,
|
||||||
base_url: "".to_owned(),
|
base_url: String::new(),
|
||||||
auth: None,
|
auth: None,
|
||||||
settings: Settings::default(),
|
settings: Settings::default(),
|
||||||
cache_dir,
|
cache_dir,
|
||||||
|
|||||||
@ -4,12 +4,12 @@ use crate::{database::models::data::DownloadableMetadata, AppState};
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn pause_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
pub fn pause_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
||||||
state.lock().unwrap().download_manager.pause_downloads()
|
state.lock().unwrap().download_manager.pause_downloads();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn resume_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
pub fn resume_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
||||||
state.lock().unwrap().download_manager.resume_downloads()
|
state.lock().unwrap().download_manager.resume_downloads();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@ -22,10 +22,10 @@ pub fn move_download_in_queue(
|
|||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.download_manager
|
.download_manager
|
||||||
.rearrange(old_index, new_index)
|
.rearrange(old_index, new_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn cancel_game(state: tauri::State<'_, Mutex<AppState>>, meta: DownloadableMetadata) {
|
pub fn cancel_game(state: tauri::State<'_, Mutex<AppState>>, meta: DownloadableMetadata) {
|
||||||
state.lock().unwrap().download_manager.cancel(meta)
|
state.lock().unwrap().download_manager.cancel(meta);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -176,7 +176,7 @@ impl DownloadManagerBuilder {
|
|||||||
DownloadManagerSignal::Cancel(meta) => {
|
DownloadManagerSignal::Cancel(meta) => {
|
||||||
self.manage_cancel_signal(&meta);
|
self.manage_cancel_signal(&meta);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn manage_queue_signal(&mut self, download_agent: DownloadAgent) {
|
fn manage_queue_signal(&mut self, download_agent: DownloadAgent) {
|
||||||
|
|||||||
@ -23,13 +23,13 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub enum DownloadManagerSignal {
|
pub enum DownloadManagerSignal {
|
||||||
/// Resumes (or starts) the DownloadManager
|
/// Resumes (or starts) the `DownloadManager`
|
||||||
Go,
|
Go,
|
||||||
/// Pauses the DownloadManager
|
/// Pauses the `DownloadManager`
|
||||||
Stop,
|
Stop,
|
||||||
/// Called when a DownloadAgent has fully completed a download.
|
/// Called when a `DownloadAgent` has fully completed a download.
|
||||||
Completed(DownloadableMetadata),
|
Completed(DownloadableMetadata),
|
||||||
/// Generates and appends a DownloadAgent
|
/// Generates and appends a `DownloadAgent`
|
||||||
/// to the registry and queue
|
/// to the registry and queue
|
||||||
Queue(DownloadAgent),
|
Queue(DownloadAgent),
|
||||||
/// Tells the Manager to stop the current
|
/// Tells the Manager to stop the current
|
||||||
@ -70,14 +70,14 @@ pub enum DownloadStatus {
|
|||||||
Error,
|
Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accessible front-end for the DownloadManager
|
/// Accessible front-end for the `DownloadManager`
|
||||||
///
|
///
|
||||||
/// The system works entirely through signals, both internally and externally,
|
/// The system works entirely through signals, both internally and externally,
|
||||||
/// all of which are accessible through the DownloadManagerSignal type, but
|
/// all of which are accessible through the `DownloadManagerSignal` type, but
|
||||||
/// should not be used directly. Rather, signals are abstracted through this
|
/// should not be used directly. Rather, signals are abstracted through this
|
||||||
/// interface.
|
/// interface.
|
||||||
///
|
///
|
||||||
/// The actual download queue may be accessed through the .edit() function,
|
/// The actual download queue may be accessed through the .`edit()` function,
|
||||||
/// which provides raw access to the underlying queue.
|
/// which provides raw access to the underlying queue.
|
||||||
/// THIS EDITING IS BLOCKING!!!
|
/// THIS EDITING IS BLOCKING!!!
|
||||||
pub struct DownloadManager {
|
pub struct DownloadManager {
|
||||||
@ -139,7 +139,7 @@ impl DownloadManager {
|
|||||||
pub fn rearrange(&self, current_index: usize, new_index: usize) {
|
pub fn rearrange(&self, current_index: usize, new_index: usize) {
|
||||||
if current_index == new_index {
|
if current_index == new_index {
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
let needs_pause = current_index == 0 || new_index == 0;
|
let needs_pause = current_index == 0 || new_index == 0;
|
||||||
if needs_pause {
|
if needs_pause {
|
||||||
@ -183,7 +183,7 @@ impl DownloadManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes in the locked value from .edit() and attempts to
|
/// Takes in the locked value from .`edit()` and attempts to
|
||||||
/// get the index of whatever id is passed in
|
/// get the index of whatever id is passed in
|
||||||
fn get_index_from_id(
|
fn get_index_from_id(
|
||||||
queue: &mut MutexGuard<'_, VecDeque<DownloadableMetadata>>,
|
queue: &mut MutexGuard<'_, VecDeque<DownloadableMetadata>>,
|
||||||
|
|||||||
@ -22,10 +22,7 @@ impl From<DownloadThreadControlFlag> for bool {
|
|||||||
/// false => Stop
|
/// false => Stop
|
||||||
impl From<bool> for DownloadThreadControlFlag {
|
impl From<bool> for DownloadThreadControlFlag {
|
||||||
fn from(value: bool) -> Self {
|
fn from(value: bool) -> Self {
|
||||||
match value {
|
if value { DownloadThreadControlFlag::Go } else { DownloadThreadControlFlag::Stop }
|
||||||
true => DownloadThreadControlFlag::Go,
|
|
||||||
false => DownloadThreadControlFlag::Stop,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ pub struct RollingProgressWindow<const S: usize> {
|
|||||||
impl<const S: usize> RollingProgressWindow<S> {
|
impl<const S: usize> RollingProgressWindow<S> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
window: Arc::new([(); S].map(|_| AtomicUsize::new(0))),
|
window: Arc::new([(); S].map(|()| AtomicUsize::new(0))),
|
||||||
current: Arc::new(AtomicUsize::new(0)),
|
current: Arc::new(AtomicUsize::new(0)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ impl Display for RemoteAccessError {
|
|||||||
error,
|
error,
|
||||||
error
|
error
|
||||||
.source()
|
.source()
|
||||||
.map(|e| e.to_string())
|
.map(std::string::ToString::to_string)
|
||||||
.or_else(|| Some("Unknown error".to_string()))
|
.or_else(|| Some("Unknown error".to_string()))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
)
|
)
|
||||||
|
|||||||
@ -115,7 +115,7 @@ impl GameDownloadAgent {
|
|||||||
);
|
);
|
||||||
let res = self
|
let res = self
|
||||||
.run()
|
.run()
|
||||||
.map_err(|_| ApplicationDownloadError::DownloadError);
|
.map_err(|()| ApplicationDownloadError::DownloadError);
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
"{} took {}ms to download",
|
"{} took {}ms to download",
|
||||||
@ -322,7 +322,7 @@ impl GameDownloadAgent {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let newly_completed = completed_contexts.to_owned();
|
let newly_completed = completed_contexts.clone();
|
||||||
|
|
||||||
let completed_lock_len = {
|
let completed_lock_len = {
|
||||||
let mut context_map_lock = self.context_map.lock().unwrap();
|
let mut context_map_lock = self.context_map.lock().unwrap();
|
||||||
@ -338,7 +338,7 @@ impl GameDownloadAgent {
|
|||||||
.map(|x| {
|
.map(|x| {
|
||||||
(
|
(
|
||||||
x.checksum.clone(),
|
x.checksum.clone(),
|
||||||
context_map_lock.get(&x.checksum).cloned().unwrap_or(false),
|
context_map_lock.get(&x.checksum).copied().unwrap_or(false),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect::<Vec<(String, bool)>>();
|
.collect::<Vec<(String, bool)>>();
|
||||||
|
|||||||
@ -151,7 +151,7 @@ pub fn download_game_chunk(
|
|||||||
return Err(ApplicationDownloadError::Communication(
|
return Err(ApplicationDownloadError::Communication(
|
||||||
RemoteAccessError::InvalidResponse(err),
|
RemoteAccessError::InvalidResponse(err),
|
||||||
));
|
));
|
||||||
};
|
}
|
||||||
return Err(ApplicationDownloadError::Communication(
|
return Err(ApplicationDownloadError::Communication(
|
||||||
RemoteAccessError::UnparseableResponse(raw_res),
|
RemoteAccessError::UnparseableResponse(raw_res),
|
||||||
));
|
));
|
||||||
@ -187,7 +187,7 @@ pub fn download_game_chunk(
|
|||||||
.map_err(|e| ApplicationDownloadError::IoError(e.kind()))?;
|
.map_err(|e| ApplicationDownloadError::IoError(e.kind()))?;
|
||||||
if !completed {
|
if !completed {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
};
|
}
|
||||||
|
|
||||||
// If we complete the file, set the permissions (if on Linux)
|
// If we complete the file, set the permissions (if on Linux)
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
|||||||
@ -38,12 +38,9 @@ pub mod v1 {
|
|||||||
|
|
||||||
impl DropData {
|
impl DropData {
|
||||||
pub fn generate(game_id: String, game_version: String, base_path: PathBuf) -> Self {
|
pub fn generate(game_id: String, game_version: String, base_path: PathBuf) -> Self {
|
||||||
let mut file = match File::open(base_path.join(DROP_DATA_PATH)) {
|
let mut file = if let Ok(file) = File::open(base_path.join(DROP_DATA_PATH)) { file } else {
|
||||||
Ok(file) => file,
|
debug!("Generating new dropdata for game {game_id}");
|
||||||
Err(_) => {
|
return DropData::new(game_id, game_version, base_path);
|
||||||
debug!("Generating new dropdata for game {game_id}");
|
|
||||||
return DropData::new(game_id, game_version, base_path);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut s = Vec::new();
|
let mut s = Vec::new();
|
||||||
@ -53,7 +50,7 @@ impl DropData {
|
|||||||
error!("{e}");
|
error!("{e}");
|
||||||
return DropData::new(game_id, game_version, base_path);
|
return DropData::new(game_id, game_version, base_path);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
match native_model::rmp_serde_1_3::RmpSerde::decode(s) {
|
match native_model::rmp_serde_1_3::RmpSerde::decode(s) {
|
||||||
Ok(manifest) => manifest,
|
Ok(manifest) => manifest,
|
||||||
@ -78,9 +75,9 @@ impl DropData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match file.write_all(&manifest_raw) {
|
match file.write_all(&manifest_raw) {
|
||||||
Ok(_) => {}
|
Ok(()) => {}
|
||||||
Err(e) => error!("{e}"),
|
Err(e) => error!("{e}"),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
pub fn set_contexts(&self, completed_contexts: &[(String, bool)]) {
|
pub fn set_contexts(&self, completed_contexts: &[(String, bool)]) {
|
||||||
*self.contexts.lock().unwrap() = completed_contexts.iter().map(|s| (s.0.clone(), s.1)).collect();
|
*self.contexts.lock().unwrap() = completed_contexts.iter().map(|s| (s.0.clone(), s.1)).collect();
|
||||||
|
|||||||
@ -125,7 +125,7 @@ pub fn validate_game_chunk(
|
|||||||
validate_copy(&mut source, &mut hasher, ctx.length, control_flag, progress).unwrap();
|
validate_copy(&mut source, &mut hasher, ctx.length, control_flag, progress).unwrap();
|
||||||
if !completed {
|
if !completed {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
};
|
}
|
||||||
|
|
||||||
let res = hex::encode(hasher.compute().0);
|
let res = hex::encode(hasher.compute().0);
|
||||||
if res != ctx.checksum {
|
if res != ctx.checksum {
|
||||||
|
|||||||
@ -96,7 +96,7 @@ pub fn fetch_library_logic(
|
|||||||
|
|
||||||
let mut db_handle = borrow_db_mut_checked();
|
let mut db_handle = borrow_db_mut_checked();
|
||||||
|
|
||||||
for game in games.iter() {
|
for game in &games {
|
||||||
handle.games.insert(game.id.clone(), game.clone());
|
handle.games.insert(game.id.clone(), game.clone());
|
||||||
if !db_handle.applications.game_statuses.contains_key(&game.id) {
|
if !db_handle.applications.game_statuses.contains_key(&game.id) {
|
||||||
db_handle
|
db_handle
|
||||||
@ -329,37 +329,34 @@ pub fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle)
|
|||||||
drop(db_handle);
|
drop(db_handle);
|
||||||
|
|
||||||
let app_handle = app_handle.clone();
|
let app_handle = app_handle.clone();
|
||||||
spawn(move || match remove_dir_all(install_dir) {
|
spawn(move || if let Err(e) = remove_dir_all(install_dir) {
|
||||||
Err(e) => {
|
error!("{e}");
|
||||||
error!("{e}");
|
} else {
|
||||||
}
|
let mut db_handle = borrow_db_mut_checked();
|
||||||
Ok(_) => {
|
db_handle.applications.transient_statuses.remove(&meta);
|
||||||
let mut db_handle = borrow_db_mut_checked();
|
db_handle
|
||||||
db_handle.applications.transient_statuses.remove(&meta);
|
.applications
|
||||||
db_handle
|
.installed_game_version
|
||||||
.applications
|
.remove(&meta.id);
|
||||||
.installed_game_version
|
db_handle
|
||||||
.remove(&meta.id);
|
.applications
|
||||||
db_handle
|
.game_statuses
|
||||||
.applications
|
.entry(meta.id.clone())
|
||||||
.game_statuses
|
.and_modify(|e| *e = GameDownloadStatus::Remote {});
|
||||||
.entry(meta.id.clone())
|
drop(db_handle);
|
||||||
.and_modify(|e| *e = GameDownloadStatus::Remote {});
|
|
||||||
drop(db_handle);
|
|
||||||
|
|
||||||
debug!("uninstalled game id {}", &meta.id);
|
debug!("uninstalled game id {}", &meta.id);
|
||||||
app_handle.emit("update_library", ()).unwrap();
|
app_handle.emit("update_library", ()).unwrap();
|
||||||
|
|
||||||
push_game_update(
|
push_game_update(
|
||||||
&app_handle,
|
&app_handle,
|
||||||
&meta.id,
|
&meta.id,
|
||||||
None,
|
None,
|
||||||
(Some(GameDownloadStatus::Remote {}), None),
|
(Some(GameDownloadStatus::Remote {}), None),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
warn!("invalid previous state for uninstall, failing silently.")
|
warn!("invalid previous state for uninstall, failing silently.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -163,7 +163,7 @@ fn setup(handle: AppHandle) -> AppState<'static> {
|
|||||||
let mut missing_games = Vec::new();
|
let mut missing_games = Vec::new();
|
||||||
let statuses = db_handle.applications.game_statuses.clone();
|
let statuses = db_handle.applications.game_statuses.clone();
|
||||||
drop(db_handle);
|
drop(db_handle);
|
||||||
for (game_id, status) in statuses.into_iter() {
|
for (game_id, status) in statuses {
|
||||||
match status {
|
match status {
|
||||||
GameDownloadStatus::Remote {} => {}
|
GameDownloadStatus::Remote {} => {}
|
||||||
GameDownloadStatus::PartiallyInstalled { .. } => {}
|
GameDownloadStatus::PartiallyInstalled { .. } => {}
|
||||||
@ -344,7 +344,7 @@ pub fn run() {
|
|||||||
let binding = event.urls();
|
let binding = event.urls();
|
||||||
let url = binding.first().unwrap();
|
let url = binding.first().unwrap();
|
||||||
if url.host_str().unwrap() == "handshake" {
|
if url.host_str().unwrap() == "handshake" {
|
||||||
recieve_handshake(handle.clone(), url.path().to_string())
|
recieve_handshake(handle.clone(), url.path().to_string());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -2,5 +2,5 @@
|
|||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
drop_app_lib::run()
|
drop_app_lib::run();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,9 +17,9 @@ pub fn launch_game(
|
|||||||
//};
|
//};
|
||||||
|
|
||||||
match process_manager_lock.launch_process(id) {
|
match process_manager_lock.launch_process(id) {
|
||||||
Ok(_) => {}
|
Ok(()) => {}
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
};
|
}
|
||||||
|
|
||||||
drop(process_manager_lock);
|
drop(process_manager_lock);
|
||||||
drop(state_lock);
|
drop(state_lock);
|
||||||
|
|||||||
@ -281,7 +281,7 @@ impl ProcessManager<'_> {
|
|||||||
let launch_string = game_launcher.create_launch_process(
|
let launch_string = game_launcher.create_launch_process(
|
||||||
&meta,
|
&meta,
|
||||||
launch.to_string(),
|
launch.to_string(),
|
||||||
args.to_vec(),
|
args.clone(),
|
||||||
game_version,
|
game_version,
|
||||||
install_dir,
|
install_dir,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -81,11 +81,11 @@ pub fn fetch_user() -> Result<User, RemoteAccessError> {
|
|||||||
return Err(RemoteAccessError::InvalidResponse(err));
|
return Err(RemoteAccessError::InvalidResponse(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
response.json::<User>().map_err(|e| e.into())
|
response.json::<User>().map_err(std::convert::Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn recieve_handshake_logic(app: &AppHandle, path: String) -> Result<(), RemoteAccessError> {
|
fn recieve_handshake_logic(app: &AppHandle, path: String) -> Result<(), RemoteAccessError> {
|
||||||
let path_chunks: Vec<&str> = path.split("/").collect();
|
let path_chunks: Vec<&str> = path.split('/').collect();
|
||||||
if path_chunks.len() != 3 {
|
if path_chunks.len() != 3 {
|
||||||
app.emit("auth/failed", ()).unwrap();
|
app.emit("auth/failed", ()).unwrap();
|
||||||
return Err(RemoteAccessError::HandshakeFailed(
|
return Err(RemoteAccessError::HandshakeFailed(
|
||||||
@ -101,8 +101,8 @@ fn recieve_handshake_logic(app: &AppHandle, path: String) -> Result<(), RemoteAc
|
|||||||
let client_id = path_chunks.get(1).unwrap();
|
let client_id = path_chunks.get(1).unwrap();
|
||||||
let token = path_chunks.get(2).unwrap();
|
let token = path_chunks.get(2).unwrap();
|
||||||
let body = HandshakeRequestBody {
|
let body = HandshakeRequestBody {
|
||||||
client_id: client_id.to_string(),
|
client_id: (*client_id).to_string(),
|
||||||
token: token.to_string(),
|
token: (*token).to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let endpoint = base_url.join("/api/v1/client/auth/handshake")?;
|
let endpoint = base_url.join("/api/v1/client/auth/handshake")?;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ pub async fn fetch_object(request: http::Request<Vec<u8>>, responder: UriSchemeR
|
|||||||
match cache_result {
|
match cache_result {
|
||||||
Ok(cache_result) => responder.respond(cache_result.into()),
|
Ok(cache_result) => responder.respond(cache_result.into()),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!("{e}")
|
warn!("{e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user