exact single file bundle

This commit is contained in:
2026-04-14 18:01:42 +08:00
parent 83279e0253
commit c015383f1d
6 changed files with 52 additions and 24 deletions
+5 -8
View File
@@ -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);
+2 -2
View File
@@ -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 {