mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-09 20:12:14 +10:00
migrated unpacking to rust zstd to conform with droplet
@drop/droplet now packs with zstd, so converts unpacker.rs to use zstd
This commit is contained in:
@ -20,5 +20,6 @@
|
||||
"vite": "^5.3.1",
|
||||
"vue-tsc": "^2.0.22",
|
||||
"@tauri-apps/cli": ">=2.0.0"
|
||||
}
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||
}
|
||||
|
||||
63
src-tauri/Cargo.lock
generated
63
src-tauri/Cargo.lock
generated
@ -1,6 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
@ -278,6 +278,8 @@ version = "1.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8d9e0b4957f635b8d3da819d0db5603620467ecf1f692d22a8c2717ce27e6d8"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
@ -689,7 +691,7 @@ dependencies = [
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-shell",
|
||||
"xz2",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1535,6 +1537,15 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.70"
|
||||
@ -1663,17 +1674,6 @@ version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "lzma-sys"
|
||||
version = "0.1.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mac"
|
||||
version = "0.1.1"
|
||||
@ -4307,15 +4307,6 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xz2"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2"
|
||||
dependencies = [
|
||||
"lzma-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
@ -4336,3 +4327,31 @@ dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9"
|
||||
dependencies = [
|
||||
"zstd-safe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd-safe"
|
||||
version = "7.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059"
|
||||
dependencies = [
|
||||
"zstd-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zstd-sys"
|
||||
version = "2.0.13+zstd.1.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
@ -23,5 +23,5 @@ tauri-plugin-shell = "2.0.0"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
ciborium = "0.2.2"
|
||||
xz2 = "0.1.7"
|
||||
zstd = "0.13.2"
|
||||
rayon = "1.10.0"
|
||||
|
||||
@ -4,12 +4,11 @@ use serde::Deserialize;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs::{create_dir_all, File},
|
||||
io::{self, BufReader, Error, Seek},
|
||||
io::{self, BufReader, Error, Seek, Write},
|
||||
os::unix::fs::PermissionsExt,
|
||||
path::Path,
|
||||
};
|
||||
use tauri::Runtime;
|
||||
use xz2::bufread::XzDecoder;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct ManifestChunk {
|
||||
@ -28,31 +27,6 @@ struct Manifest {
|
||||
record: HashMap<String, ManifestRecord>,
|
||||
}
|
||||
|
||||
fn generate_permissions(permissions: Vec<bool>) -> u32 {
|
||||
// Base 8
|
||||
let mut perms: u32 = 0;
|
||||
|
||||
// Read
|
||||
if permissions[0] {
|
||||
perms += 4;
|
||||
}
|
||||
|
||||
// Write
|
||||
if permissions[1] {
|
||||
perms += 2;
|
||||
}
|
||||
|
||||
// Execute
|
||||
if permissions[2] {
|
||||
perms += 1;
|
||||
}
|
||||
|
||||
perms *= 8 * 8;
|
||||
perms += 4 * 8 + 4;
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
pub fn unpack() -> Result<(), Error> {
|
||||
let chunk_size: u64 = 1024 * 1024 * 16;
|
||||
|
||||
@ -80,12 +54,13 @@ pub fn unpack() -> Result<(), Error> {
|
||||
let chunk_handle = File::open(chunk_path).unwrap();
|
||||
|
||||
let chunk_reader = BufReader::new(chunk_handle);
|
||||
let mut decompressor = XzDecoder::new(chunk_reader);
|
||||
let mut decompressor = zstd::Decoder::new(chunk_reader).unwrap();
|
||||
|
||||
let offset = u64::try_from(chunk.index).unwrap() * chunk_size;
|
||||
file_handle.seek(io::SeekFrom::Start(offset)).unwrap();
|
||||
|
||||
io::copy(&mut decompressor, &mut file_handle).unwrap();
|
||||
file_handle.flush().unwrap();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user