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
+30 -9
View File
@@ -41,7 +41,12 @@ pub async fn download(
send_error(send_response, error.into());
return Ok(());
}
let dir = dir.unwrap();
let (dir, single_file) = dir.unwrap();
let dir_base = std::env::temp_dir()
.join("sekai-updater")
.join("extract")
.join(&context.sync_context.region);
let files = if !dir.is_dir() {
if context.sync_context.filters.file_ext.is_empty()
@@ -53,7 +58,13 @@ pub async fn download(
.contains(&t.to_str().unwrap().to_lowercase())
})
{
vec![dir.clone()]
vec![(
dir.clone(),
dir.strip_prefix(&dir_base)
.unwrap()
.to_string_lossy()
.to_string(),
)]
} else {
vec![]
}
@@ -67,7 +78,22 @@ pub async fn download(
send_error(send_response, error.into());
return Ok(());
}
files.unwrap()
let base = dir.strip_prefix(&dir_base).unwrap();
let base_str = if single_file {
base.parent().unwrap().to_str().unwrap()
} else {
base.to_str().unwrap()
};
files
.unwrap()
.iter()
.map(|p| {
let raw = p.clone();
let name = p.strip_prefix(&dir).unwrap();
let path = format!("{}/{}", base_str, name.to_string_lossy());
(raw, path)
})
.collect::<Vec<_>>()
};
let response = Response::builder()
@@ -76,13 +102,8 @@ pub async fn download(
.body(())
.unwrap();
let dir_base = std::env::temp_dir()
.join("sekai-updater")
.join("extract")
.join(&context.sync_context.region);
if let Ok(send_stream) = send_response.send_response(response, false) {
let _ = server_send_files(send_stream, dir_base, &files).await;
let _ = server_send_files(send_stream, &files).await;
}
let _ = std::fs::remove_file(dir);