chore(downloads): partial download manager

This commit is contained in:
DecDuck
2024-11-12 09:06:28 +11:00
parent 5e3d26b3ca
commit 3dbf5ab573
5 changed files with 66 additions and 11 deletions

View File

@ -11,6 +11,7 @@ pub fn download_game(
game_version: String,
state: tauri::State<'_, Mutex<AppState>>,
) -> Result<(), String> {
/*
info!("beginning game download...");
let mut download_agent = GameDownloadAgent::new(game_id.clone(), game_version.clone(), 0);
@ -19,7 +20,7 @@ pub fn download_game(
let mut lock: std::sync::MutexGuard<'_, AppState> = state.lock().unwrap();
let download_agent_ref = Arc::new(download_agent);
lock.game_downloads
lock.download_manager
.insert(game_id, download_agent_ref.clone());
// Run it in another thread
@ -27,6 +28,7 @@ pub fn download_game(
// Run doesn't require mutable
download_agent_ref.clone().run();
});
*/
Ok(())
}
@ -36,18 +38,23 @@ pub fn get_game_download_progress(
state: tauri::State<'_, Mutex<AppState>>,
game_id: String,
) -> Result<f64, String> {
/*
let download_agent = use_download_agent(state, game_id)?;
let progress = &download_agent.progress;
Ok(progress.get_progress())
}
*/
Ok(0.0)
}
/*
fn use_download_agent(
state: tauri::State<'_, Mutex<AppState>>,
game_id: String,
) -> Result<Arc<GameDownloadAgent>, String> {
let lock = state.lock().unwrap();
let download_agent = lock.game_downloads.get(&game_id).ok_or("Invalid game ID")?;
let download_agent = lock.download_manager.get(&game_id).ok_or("Invalid game ID")?;
Ok(download_agent.clone()) // Clones the Arc, not the underlying data structure
}
*/