mirror of
https://github.com/Bluemangoo/sekai-unpacker.git
synced 2026-09-19 15:59:01 +08:00
exact single file bundle
This commit is contained in:
@@ -4,24 +4,21 @@ use std::path::Path;
|
||||
use tokio::fs::File;
|
||||
use tokio::io::{AsyncRead, AsyncReadExt};
|
||||
|
||||
pub async fn server_send_files<P: AsRef<Path>>(
|
||||
pub async fn server_send_files<P: AsRef<Path>, S: AsRef<str>>(
|
||||
mut send_stream: SendStream<Bytes>,
|
||||
base: P,
|
||||
files: &[P],
|
||||
files: &[(P, S)],
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut header = BytesMut::with_capacity(4);
|
||||
header.put_u32(files.len() as u32);
|
||||
send_stream.send_data(header.freeze(), false)?;
|
||||
|
||||
for (i, path_ref) in files.iter().enumerate() {
|
||||
let path = path_ref.as_ref();
|
||||
let path = path_ref.0.as_ref();
|
||||
let mut file = File::open(path).await?;
|
||||
let metadata = file.metadata().await?;
|
||||
|
||||
let file_name = path
|
||||
.strip_prefix(base.as_ref())
|
||||
.map(|n| n.to_string_lossy().to_string())?;
|
||||
let name_bytes = file_name.as_bytes();
|
||||
let file_name = &path_ref.1;
|
||||
let name_bytes = file_name.as_ref().as_bytes();
|
||||
let file_size = metadata.len();
|
||||
|
||||
let mut meta_buf = BytesMut::with_capacity(2 + name_bytes.len() + 8);
|
||||
|
||||
@@ -11,10 +11,10 @@ pub struct SyncContext {
|
||||
pub asset_version: Option<String>,
|
||||
#[serde(default)]
|
||||
pub asset_hash: Option<String>,
|
||||
#[serde(default)]
|
||||
pub exact_single_file_bundle: bool,
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
#[serde(default)]
|
||||
pub struct RegionFiltersConfig {
|
||||
|
||||
Reference in New Issue
Block a user