mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 00:02:41 +10:00
commit0f48f3fb44Author: quexeky <git@quexeky.dev> Date: Sun Oct 12 19:35:04 2025 +1100 chore: Run cargo clippy && cargo fmt Signed-off-by: quexeky <git@quexeky.dev> commit974666efe2Author: quexeky <git@quexeky.dev> Date: Sun Oct 12 19:17:40 2025 +1100 refactor: Finish refactor Signed-off-by: quexeky <git@quexeky.dev> commit9e1bf9852fAuthor: quexeky <git@quexeky.dev> Date: Sun Oct 12 18:33:43 2025 +1100 refactor: Builds, but some logic still left to move back Signed-off-by: quexeky <git@quexeky.dev> commit5d22b883d5Author: quexeky <git@quexeky.dev> Date: Sun Oct 12 17:04:27 2025 +1100 refactor: Improvements to src-tauri Signed-off-by: quexeky <git@quexeky.dev> commit62a2561539Author: quexeky <git@quexeky.dev> Date: Sat Oct 11 09:51:04 2025 +1100 fix: Remote tauri dependency from process Signed-off-by: quexeky <git@quexeky.dev> commit59f040bc8bAuthor: quexeky <git@quexeky.dev> Date: Thu Oct 9 07:46:17 2025 +1100 chore: Major refactoring Still needs a massive go-over because there shouldn't be anything referencing tauri in any of the workspaces except the original one. Process manager has been refactored as an example Signed-off-by: quexeky <git@quexeky.dev> Signed-off-by: quexeky <git@quexeky.dev>
99 lines
2.3 KiB
Rust
99 lines
2.3 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use std::collections::HashMap;
|
|
use std::path::PathBuf;
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
// Drops go in buckets
|
|
pub struct DownloadDrop {
|
|
pub index: usize,
|
|
pub filename: String,
|
|
pub path: PathBuf,
|
|
pub start: usize,
|
|
pub length: usize,
|
|
pub checksum: String,
|
|
pub permissions: u32,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct DownloadBucket {
|
|
pub game_id: String,
|
|
pub version: String,
|
|
pub drops: Vec<DownloadDrop>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct DownloadContext {
|
|
pub context: String,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ChunkBodyFile {
|
|
filename: String,
|
|
chunk_index: usize,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ChunkBody {
|
|
pub context: String,
|
|
pub files: Vec<ChunkBodyFile>,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub struct ManifestBody {
|
|
pub game: String,
|
|
pub version: String,
|
|
}
|
|
|
|
impl ChunkBody {
|
|
pub fn create(context: &DownloadContext, drops: &[DownloadDrop]) -> ChunkBody {
|
|
Self {
|
|
context: context.context.clone(),
|
|
files: drops
|
|
.iter()
|
|
.map(|e| ChunkBodyFile {
|
|
filename: e.filename.clone(),
|
|
chunk_index: e.index,
|
|
})
|
|
.collect(),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub type DropManifest = HashMap<String, DropChunk>;
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct DropChunk {
|
|
pub permissions: u32,
|
|
pub ids: Vec<String>,
|
|
pub checksums: Vec<String>,
|
|
pub lengths: Vec<usize>,
|
|
pub version_name: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
pub struct DropValidateContext {
|
|
pub index: usize,
|
|
pub offset: usize,
|
|
pub path: PathBuf,
|
|
pub checksum: String,
|
|
pub length: usize,
|
|
}
|
|
|
|
impl From<DownloadBucket> for Vec<DropValidateContext> {
|
|
fn from(value: DownloadBucket) -> Self {
|
|
value
|
|
.drops
|
|
.into_iter()
|
|
.map(|e| DropValidateContext {
|
|
index: e.index,
|
|
offset: e.start,
|
|
path: e.path,
|
|
checksum: e.checksum,
|
|
length: e.length,
|
|
})
|
|
.collect()
|
|
}
|
|
}
|