From 8d4b6e79f3acab2fb2a431fb7bf98a0aa2808644 Mon Sep 17 00:00:00 2001 From: Bluemangoo Date: Mon, 4 May 2026 15:26:22 +0800 Subject: [PATCH] fix export path --- assets-updater/src/core/export_pipeline.rs | 73 +++++----------------- client/src/main.rs | 6 +- client/src/task.rs | 2 +- sekai-unpacker-client.example.yaml | 6 +- sekai-unpacker-server.example.yaml | 2 +- 5 files changed, 25 insertions(+), 64 deletions(-) diff --git a/assets-updater/src/core/export_pipeline.rs b/assets-updater/src/core/export_pipeline.rs index 256be75..57e56ae 100644 --- a/assets-updater/src/core/export_pipeline.rs +++ b/assets-updater/src/core/export_pipeline.rs @@ -179,7 +179,6 @@ pub async fn post_process_exported_files( handle_usm_files( export_path, sync_context, - region, &app_config.tools.ffmpeg_path, &app_config.execution.retry, ) @@ -202,7 +201,6 @@ pub async fn post_process_exported_files( async fn handle_usm_files( export_path: &Path, sync_context: &SyncContext, - region: &RegionConfig, ffmpeg_path: &str, retry: &crate::core::config::RetryConfig, ) -> Result, ExportPipelineError> { @@ -211,28 +209,17 @@ async fn handle_usm_files( return Ok(Vec::new()); } - let usm_input = if usm_files.len() == 1 { - usm_files[0].clone() - } else { - merge_usm_files(export_path, &usm_files)? - }; + let mut out: Vec = vec![]; - process_usm_file( - &usm_input, - export_path, - sync_context, - region, - ffmpeg_path, - retry, - ) - .await + for f in usm_files { + out.append(&mut process_usm_file(&f, sync_context, ffmpeg_path, retry).await?); + } + Ok(out) } async fn process_usm_file( usm_file: &Path, - export_path: &Path, sync_context: &SyncContext, - _: &RegionConfig, ffmpeg_path: &str, retry: &crate::core::config::RetryConfig, ) -> Result, ExportPipelineError> { @@ -248,7 +235,10 @@ async fn process_usm_file( if sync_context.export.video.convert_to_mp4 && sync_context.export.video.direct_usm_to_mp4_with_ffmpeg { - let mp4 = export_path.join(format!("{output_name}.mp4")); + let mp4 = usm_file + .parent() + .unwrap() + .join(format!("{output_name}.mp4")); convert_usm_to_mp4(usm_file, &mp4, ffmpeg_path, retry).await?; remove_file_if_exists(usm_file)?; return Ok(vec![mp4]); @@ -260,7 +250,7 @@ async fn process_usm_file( .and_then(|metadata| metadata.video_frame_rate()) .filter(|(_, denominator)| *denominator > 0) .map(FrameRate::from_tuple); - let extracted = codec::export_usm(usm_file, export_path)?; + let extracted = codec::export_usm(usm_file, usm_file.parent().unwrap())?; let mut generated = extracted.clone(); if sync_context.export.video.convert_to_mp4 { @@ -271,7 +261,10 @@ async fn process_usm_file( .map(|ext| ext.eq_ignore_ascii_case("m2v")) .unwrap_or(false) { - let mp4 = export_path.join(format!("{output_name}.mp4")); + let mp4 = usm_file + .parent() + .unwrap() + .join(format!("{output_name}.mp4")); convert_m2v_to_mp4( &extracted_file, &mp4, @@ -327,7 +320,7 @@ async fn handle_acb_files( fn process_acb_file( acb_file: &Path, - output_dir: &Path, + _output_dir: &Path, sync_context: &SyncContext, region: &RegionConfig, ffmpeg_path: &str, @@ -381,7 +374,7 @@ fn process_acb_file( &retry, ) })?; - let final_outputs = move_result_files(output_dir, &generated)?; + let final_outputs = move_result_files(acb_file.parent().unwrap(), &generated)?; remove_file_if_exists(acb_file)?; Ok(final_outputs) @@ -429,7 +422,7 @@ fn process_hca_file( generated.clear(); } - let final_outputs = move_result_files(output_dir, &generated)?; + let final_outputs = move_result_files(hca_file.parent().unwrap(), &generated)?; Ok(final_outputs) } @@ -710,38 +703,6 @@ fn panic_message(panic: Box) -> String { } } -fn merge_usm_files(dir: &Path, usm_files: &[PathBuf]) -> Result { - let dir_name = dir - .file_name() - .and_then(|name| name.to_str()) - .unwrap_or("merged"); - let merged_file = dir.join(format!("{dir_name}.usm")); - let mut target = - std::fs::File::create(&merged_file).map_err(|source| ExportPipelineError::Io { - path: merged_file.clone(), - source, - })?; - - for source_path in usm_files { - if *source_path == merged_file { - continue; - } - let mut source = - std::fs::File::open(source_path).map_err(|source| ExportPipelineError::Io { - path: source_path.clone(), - source, - })?; - std::io::copy(&mut source, &mut target).map_err(|source| ExportPipelineError::Io { - path: source_path.clone(), - source, - })?; - drop(source); - remove_file_if_exists(source_path)?; - } - - Ok(merged_file) -} - pub fn find_files(dir: &Path) -> Result, ExportPipelineError> { let mut files = Vec::new(); walk(dir, &mut |path| { diff --git a/client/src/main.rs b/client/src/main.rs index 70ceefd..2a4b68b 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -1,7 +1,7 @@ use crate::config::{ClientConfig, Profile}; use crate::queue::SharedQueue; use crate::signal::Signal; -use crate::task::{AtomicCounters, AutoSaveManifest, post_run, run_main, run_side}; +use crate::task::{AtomicCounters, AutoSaveManifest, pre_run, run_main, run_side}; use common::strings::REGION_NOT_FOUND; use common::updater::DownloadTask; use communicator::{ClientManager, Identity, TunnelEndpoint, TunnelListener, connect_tunnel}; @@ -233,7 +233,7 @@ async fn main() -> anyhow::Result<()> { if cancel_token.is_cancelled() { return; } - let sync_id = post_run(client.clone(), profile.clone(), tasks.clone(), cnt.clone()).await; + let sync_id = pre_run(client.clone(), profile.clone(), tasks.clone(), cnt.clone()).await; let sig = signal.pick().await; let result = match sync_id { Ok(Some(id)) => { @@ -328,7 +328,7 @@ async fn main() -> anyhow::Result<()> { if cancel_token.is_cancelled() { return; } - let sync_id = post_run(client.clone(), profile.clone(), tasks.clone(), cnt.clone()).await; + let sync_id = pre_run(client.clone(), profile.clone(), tasks.clone(), cnt.clone()).await; let sig = signal.pick().await; let result = match sync_id { Ok(Some(id)) => { diff --git a/client/src/task.rs b/client/src/task.rs index cd00cc1..0dca1c1 100644 --- a/client/src/task.rs +++ b/client/src/task.rs @@ -15,7 +15,7 @@ use tokio::sync::{RwLock, Semaphore}; use tokio::task::JoinSet; use tokio_util::sync::CancellationToken; -pub async fn post_run( +pub async fn pre_run( client: Arc, profile: Arc<(String, Arc>)>, queue: SharedQueue, diff --git a/sekai-unpacker-client.example.yaml b/sekai-unpacker-client.example.yaml index 4fbfaba..c7115cf 100644 --- a/sekai-unpacker-client.example.yaml +++ b/sekai-unpacker-client.example.yaml @@ -82,7 +82,7 @@ profiles: # 并发下载数(单个资源包的同时下载线程数) concurrent: 50 - # 精确匹配单文件包 + # 展开单文件包 exact_single_file_bundle: true # 导出基础路径 @@ -93,7 +93,7 @@ profiles: # 启动应用时必须下载的资源类型 start_app: - "thumbnail" # 缩略图 - - "stamp" # 邮票/表情 + - "stamp" # 表情 # - "area" # 地图 # - "home" # 主页背景 @@ -158,7 +158,7 @@ profiles: # 并发下载数 concurrent: 50 - # 精确匹配单文件包 + # 展开单文件包 exact_single_file_bundle: true # 导出路径 diff --git a/sekai-unpacker-server.example.yaml b/sekai-unpacker-server.example.yaml index bd13217..854c74d 100644 --- a/sekai-unpacker-server.example.yaml +++ b/sekai-unpacker-server.example.yaml @@ -108,7 +108,7 @@ concurrency: # ACB 音频包解析的并发数 acb: 8 - # USM 视频解析的并发数 + # USM 视频解析的并发数(好像没用到) usm: 4 # HCA 音频解码的并发数(通常可设置较大值)