From 67a237d8a34620ce3b336d29445e632600a56b06 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Mon, 7 Oct 2024 15:00:20 +1100 Subject: [PATCH] patch issue --- package.json | 2 +- src/lib.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index c6ca427..98874c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@drop/droplet", - "version": "0.1.0", + "version": "0.1.1", "main": "index.js", "types": "index.d.ts", "napi": { diff --git a/src/lib.rs b/src/lib.rs index 9a1da03..ce446b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ use napi::Error; use std::{ collections::HashMap, fs::File, - io::{self, BufRead, BufReader}, + io::{self, BufRead, BufReader, Write}, path::Path, sync::{Arc, Mutex}, }; @@ -23,12 +23,11 @@ pub mod manifest; #[macro_use] extern crate napi_derive; -fn compress(mut buffer: &[u8], output_path: &Path, chunk_id: Uuid) { +fn compress(buffer: &[u8], output_path: &Path, chunk_id: Uuid) { let chunk_path = output_path.join(chunk_id.to_string() + ".bin"); let chunk_file = File::create_new(chunk_path).unwrap(); - let mut compressor = zstd::Encoder::new(chunk_file, 5).unwrap(); - io::copy(&mut buffer, &mut compressor).unwrap(); + zstd::stream::copy_encode(buffer, chunk_file, 7).unwrap(); } #[napi] @@ -113,7 +112,7 @@ pub async fn repack(source: String, output: String) -> Result<(), Error> { println!("Queued {}", file_path.to_str().unwrap()); } - + let manifest_path = output_path.join("manifest.drop"); generate_manifest(manifest, &manifest_path); });