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:
parent
cdf617b5c3
commit
cc4e6f0615
@ -59,6 +59,17 @@ pub fn get_hex_index(input: &str) -> String {
|
||||
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(
|
||||
app_config: &AppConfig,
|
||||
sync_context: &SyncContext,
|
||||
@ -69,11 +80,13 @@ pub async fn extract_unity_asset_bundle(
|
||||
category: &str,
|
||||
) -> Result<(PathBuf, bool), ExportPipelineError> {
|
||||
let hash = get_hex_index(export_path);
|
||||
let output_dir = std::env::temp_dir()
|
||||
.join("sekai-updater")
|
||||
.join("extract")
|
||||
.join(&sync_context.region)
|
||||
.join(hash);
|
||||
let output_dir = empty_dir(
|
||||
std::env::temp_dir()
|
||||
.join("sekai-updater")
|
||||
.join("extract")
|
||||
.join(&sync_context.region),
|
||||
hash,
|
||||
);
|
||||
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));
|
||||
};
|
||||
|
||||
@ -86,7 +86,7 @@ pub async fn download(
|
||||
let _ = server_send_files(send_stream, &files).await;
|
||||
}
|
||||
|
||||
let _ = std::fs::remove_file(dir);
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user