mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-20 19:51:13 +10:00
refactor: Rename StoredManifest to DropData
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@ -27,7 +27,7 @@ use tauri::{AppHandle, Emitter};
|
|||||||
use rustix::fs::{fallocate, FallocateFlags};
|
use rustix::fs::{fallocate, FallocateFlags};
|
||||||
|
|
||||||
use super::download_logic::download_game_chunk;
|
use super::download_logic::download_game_chunk;
|
||||||
use super::stored_manifest::StoredManifest;
|
use super::drop_data::DropData;
|
||||||
|
|
||||||
pub struct GameDownloadAgent {
|
pub struct GameDownloadAgent {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
@ -38,7 +38,7 @@ pub struct GameDownloadAgent {
|
|||||||
pub manifest: Mutex<Option<DropManifest>>,
|
pub manifest: Mutex<Option<DropManifest>>,
|
||||||
pub progress: Arc<ProgressObject>,
|
pub progress: Arc<ProgressObject>,
|
||||||
sender: Sender<DownloadManagerSignal>,
|
sender: Sender<DownloadManagerSignal>,
|
||||||
pub stored_manifest: StoredManifest,
|
pub stored_manifest: DropData,
|
||||||
status: Mutex<DownloadStatus>,
|
status: Mutex<DownloadStatus>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ impl GameDownloadAgent {
|
|||||||
let data_base_dir_path = base_dir_path.join(id.clone());
|
let data_base_dir_path = base_dir_path.join(id.clone());
|
||||||
|
|
||||||
let stored_manifest =
|
let stored_manifest =
|
||||||
StoredManifest::generate(id.clone(), version.clone(), data_base_dir_path.clone());
|
DropData::generate(id.clone(), version.clone(), data_base_dir_path.clone());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use serde_binary::binary_stream::Endian;
|
use serde_binary::binary_stream::Endian;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct StoredManifest {
|
pub struct DropData {
|
||||||
game_id: String,
|
game_id: String,
|
||||||
game_version: String,
|
game_version: String,
|
||||||
pub completed_contexts: Mutex<Vec<usize>>,
|
pub completed_contexts: Mutex<Vec<usize>>,
|
||||||
@ -19,7 +19,7 @@ pub struct StoredManifest {
|
|||||||
|
|
||||||
static DROP_DATA_PATH: &str = ".dropdata";
|
static DROP_DATA_PATH: &str = ".dropdata";
|
||||||
|
|
||||||
impl StoredManifest {
|
impl DropData {
|
||||||
pub fn new(game_id: String, game_version: String, base_path: PathBuf) -> Self {
|
pub fn new(game_id: String, game_version: String, base_path: PathBuf) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base_path,
|
base_path,
|
||||||
@ -31,7 +31,7 @@ impl StoredManifest {
|
|||||||
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 = match File::open(base_path.join(DROP_DATA_PATH)) {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(_) => return StoredManifest::new(game_id, game_version, base_path),
|
Err(_) => return DropData::new(game_id, game_version, base_path),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut s = Vec::new();
|
let mut s = Vec::new();
|
||||||
@ -39,15 +39,15 @@ impl StoredManifest {
|
|||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("{}", e);
|
error!("{}", e);
|
||||||
return StoredManifest::new(game_id, game_version, base_path);
|
return DropData::new(game_id, game_version, base_path);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match serde_binary::from_vec::<StoredManifest>(s, Endian::Little) {
|
match serde_binary::from_vec::<DropData>(s, Endian::Little) {
|
||||||
Ok(manifest) => manifest,
|
Ok(manifest) => manifest,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!("{}", e);
|
warn!("{}", e);
|
||||||
StoredManifest::new(game_id, game_version, base_path)
|
DropData::new(game_id, game_version, base_path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,4 +2,4 @@ pub mod commands;
|
|||||||
pub mod download_agent;
|
pub mod download_agent;
|
||||||
mod download_logic;
|
mod download_logic;
|
||||||
mod manifest;
|
mod manifest;
|
||||||
mod stored_manifest;
|
mod drop_data;
|
||||||
|
|||||||
Reference in New Issue
Block a user