mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-24 17:03:00 +10:00
feat(download manager): Added generic download manager
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@@ -1,16 +1,26 @@
|
||||
use std::sync::Mutex;
|
||||
|
||||
use crate::{download_manager::downloadable_metadata::DownloadableMetadata, AppState};
|
||||
use crate::{db::GameDownloadStatus, download_manager::downloadable_metadata::{DownloadType, DownloadableMetadata}, AppState, DB};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn launch_game(
|
||||
game_id: DownloadableMetadata,
|
||||
id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<(), String> {
|
||||
let state_lock = state.lock().unwrap();
|
||||
let mut process_manager_lock = state_lock.process_manager.lock().unwrap();
|
||||
|
||||
process_manager_lock.launch_process(game_id)?;
|
||||
let version = match DB.borrow_data().unwrap().applications.game_statuses.get(&id).cloned() {
|
||||
Some(GameDownloadStatus::Installed { version_name, install_dir }) => version_name,
|
||||
Some(GameDownloadStatus::SetupRequired { version_name, install_dir }) => return Err(String::from("Game setup still required")),
|
||||
_ => return Err(String::from("Game not installed"))
|
||||
};
|
||||
|
||||
|
||||
let meta = DownloadableMetadata { id, version: Some(version), download_type: DownloadType::Game };
|
||||
|
||||
|
||||
process_manager_lock.launch_process(meta)?;
|
||||
|
||||
drop(process_manager_lock);
|
||||
drop(state_lock);
|
||||
|
||||
Reference in New Issue
Block a user