feat: provide rusty manifest

This commit is contained in:
DecDuck
2025-12-13 21:28:20 +11:00
parent ed0b7bcf42
commit e37e3f620b
3 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -219,7 +219,7 @@ dependencies = [
[[package]] [[package]]
name = "droplet-rs" name = "droplet-rs"
version = "0.11.0" version = "0.11.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
+1 -1
View File
@@ -2,7 +2,7 @@
edition = "2021" edition = "2021"
authors = ["Drop-OSS"] authors = ["Drop-OSS"]
name = "droplet-rs" name = "droplet-rs"
version = "0.11.0" version = "0.11.1"
license = "AGPL-3.0-only" license = "AGPL-3.0-only"
description = "Droplet is a `napi.rs` Rust/Node.js package full of high-performance and low-level utils for Drop" description = "Droplet is a `napi.rs` Rust/Node.js package full of high-performance and low-level utils for Drop"
+5 -6
View File
@@ -18,7 +18,7 @@ use sha2::{Digest as _, Sha256};
use tokio::{io::AsyncReadExt as _, join, sync::Mutex}; use tokio::{io::AsyncReadExt as _, join, sync::Mutex};
#[derive(Serialize, Clone)] #[derive(Serialize, Clone)]
struct FileEntry { pub struct FileEntry {
filename: String, filename: String,
start: usize, start: usize,
length: usize, length: usize,
@@ -26,13 +26,13 @@ struct FileEntry {
} }
#[derive(Serialize, Clone)] #[derive(Serialize, Clone)]
struct ChunkData { pub struct ChunkData {
files: Vec<FileEntry>, files: Vec<FileEntry>,
checksum: String, checksum: String,
} }
#[derive(Serialize)] #[derive(Serialize)]
struct Manifest { pub struct Manifest {
version: String, version: String,
chunks: HashMap<String, ChunkData>, chunks: HashMap<String, ChunkData>,
size: u64, size: u64,
@@ -47,7 +47,7 @@ pub async fn generate_manifest_rusty<T: Fn(String), V: Fn(f32)>(
dir: &Path, dir: &Path,
progress_sfn: V, progress_sfn: V,
log_sfn: T, log_sfn: T,
) -> anyhow::Result<String> { ) -> anyhow::Result<Manifest> {
let mut backend = let mut backend =
create_backend_constructor(dir).ok_or(anyhow!("Could not create backend for path."))?()?; create_backend_constructor(dir).ok_or(anyhow!("Could not create backend for path."))?()?;
@@ -222,10 +222,9 @@ pub async fn generate_manifest_rusty<T: Fn(String), V: Fn(f32)>(
let manifest = manifest.lock().await; let manifest = manifest.lock().await;
let manifest = manifest.clone(); let manifest = manifest.clone();
Ok(json!(Manifest { Ok(Manifest {
version: "2".to_string(), version: "2".to_string(),
chunks: manifest, chunks: manifest,
size: total_manifest_length.fetch_add(0, Ordering::Relaxed) size: total_manifest_length.fetch_add(0, Ordering::Relaxed)
}) })
.to_string())
} }