1
0
mirror of https://github.com/Bluemangoo/sekai-unpacker.git synced 2026-05-06 20:44:47 +08:00

fix temp create&remove

This commit is contained in:
Bluemangoo 2026-04-29 21:15:44 +08:00
parent cdf617b5c3
commit cc4e6f0615
Signed by: Bluemangoo
GPG Key ID: F2F7E46880A1C4CF
2 changed files with 19 additions and 6 deletions

View File

@ -59,6 +59,17 @@ pub fn get_hex_index(input: &str) -> String {
format!("{:032x}", hash_val) format!("{:032x}", hash_val)
} }
pub fn empty_dir(base: PathBuf, name: String) -> PathBuf {
let mut dir = base.join(&name);
let mut cnt = 1;
while dir.exists() {
dir = base.join(format!("{}_{}", &name, cnt));
cnt += 1;
}
std::fs::create_dir_all(&dir).unwrap();
dir
}
pub async fn extract_unity_asset_bundle( pub async fn extract_unity_asset_bundle(
app_config: &AppConfig, app_config: &AppConfig,
sync_context: &SyncContext, sync_context: &SyncContext,
@ -69,11 +80,13 @@ pub async fn extract_unity_asset_bundle(
category: &str, category: &str,
) -> Result<(PathBuf, bool), ExportPipelineError> { ) -> Result<(PathBuf, bool), ExportPipelineError> {
let hash = get_hex_index(export_path); let hash = get_hex_index(export_path);
let output_dir = std::env::temp_dir() let output_dir = empty_dir(
std::env::temp_dir()
.join("sekai-updater") .join("sekai-updater")
.join("extract") .join("extract")
.join(&sync_context.region) .join(&sync_context.region),
.join(hash); hash,
);
let Some(asset_studio_cli_path) = app_config.tools.asset_studio_cli_path.as_deref() else { let Some(asset_studio_cli_path) = app_config.tools.asset_studio_cli_path.as_deref() else {
return Ok((asset_bundle_file.parent().unwrap().to_path_buf(), true)); return Ok((asset_bundle_file.parent().unwrap().to_path_buf(), true));
}; };

View File

@ -86,7 +86,7 @@ pub async fn download(
let _ = server_send_files(send_stream, &files).await; let _ = server_send_files(send_stream, &files).await;
} }
let _ = std::fs::remove_file(dir); let _ = std::fs::remove_dir_all(dir);
Ok(()) Ok(())
} }