mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 16:22:43 +10:00
Included in AppStatus (Also trying to link to Issue #1)
This commit is contained in:
@ -1,15 +1,20 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::AtomicUsize;
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use versions::Version;
|
use versions::Version;
|
||||||
use crate::downloads::progress::ProgressChecker;
|
use crate::downloads::progress::ProgressChecker;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
#[serde(rename_all="camelCase")]
|
||||||
pub struct GameDownload {
|
pub struct GameDownload {
|
||||||
id: String,
|
id: String,
|
||||||
version: Version,
|
version: Version,
|
||||||
progress: Arc<AtomicUsize>
|
progress: Arc<AtomicUsize>
|
||||||
}
|
}
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all="camelCase")]
|
||||||
pub struct GameChunkCtx {
|
pub struct GameChunkCtx {
|
||||||
|
chunk_id: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GameDownload {
|
impl GameDownload {
|
||||||
@ -22,9 +27,10 @@ impl GameDownload {
|
|||||||
}
|
}
|
||||||
pub async fn download(&self, max_threads: usize, contexts: Vec<GameChunkCtx>) {
|
pub async fn download(&self, max_threads: usize, contexts: Vec<GameChunkCtx>) {
|
||||||
let progress = ProgressChecker::new(Box::new(download_game_chunk), self.progress.clone());
|
let progress = ProgressChecker::new(Box::new(download_game_chunk), self.progress.clone());
|
||||||
progress.run_contexts_sequentially_async(contexts).await;
|
progress.run_contexts_parallel_async(contexts, max_threads).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn download_game_chunk(ctx: GameChunkCtx) {
|
fn download_game_chunk(ctx: GameChunkCtx) {
|
||||||
todo!()
|
todo!();
|
||||||
|
// Need to implement actual download logic
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
mod downloads;
|
mod downloads;
|
||||||
mod manifest;
|
mod manifest;
|
||||||
pub mod progress;
|
pub mod progress;
|
||||||
mod game_download;
|
pub mod game_download;
|
||||||
@ -21,6 +21,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
use tauri_plugin_deep_link::DeepLinkExt;
|
use tauri_plugin_deep_link::DeepLinkExt;
|
||||||
use crate::db::DatabaseImpls;
|
use crate::db::DatabaseImpls;
|
||||||
|
use crate::downloads::game_download::GameDownload;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Serialize)]
|
#[derive(Clone, Copy, Serialize)]
|
||||||
pub enum AppStatus {
|
pub enum AppStatus {
|
||||||
@ -45,6 +46,7 @@ pub struct AppState {
|
|||||||
status: AppStatus,
|
status: AppStatus,
|
||||||
user: Option<User>,
|
user: Option<User>,
|
||||||
games: HashMap<String, Game>,
|
games: HashMap<String, Game>,
|
||||||
|
game_downloads: Vec<GameDownload>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@ -64,6 +66,7 @@ fn setup() -> AppState {
|
|||||||
status: AppStatus::NotConfigured,
|
status: AppStatus::NotConfigured,
|
||||||
user: None,
|
user: None,
|
||||||
games: HashMap::new(),
|
games: HashMap::new(),
|
||||||
|
game_downloads: vec![],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +75,7 @@ fn setup() -> AppState {
|
|||||||
status: auth_result.0,
|
status: auth_result.0,
|
||||||
user: auth_result.1,
|
user: auth_result.1,
|
||||||
games: HashMap::new(),
|
games: HashMap::new(),
|
||||||
|
game_downloads: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user