mirror of
https://github.com/Bluemangoo/sekai-unpacker.git
synced 2026-09-20 00:06:52 +08:00
fix tons of bugs
This commit is contained in:
@@ -22,3 +22,4 @@ cridecoder = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
log = { workspace = true }
|
||||
cipher = { workspace = true, features = ["block-padding"] }
|
||||
twox-hash = { workspace = true, features = ["xxhash3_128"] }
|
||||
|
||||
@@ -262,13 +262,17 @@ impl AssetExecutionContext {
|
||||
}
|
||||
RegionProviderConfig::Nuverse {
|
||||
asset_version_url,
|
||||
app_version,
|
||||
asset_info_url_template,
|
||||
..
|
||||
} => {
|
||||
// For nuverse, always fetch the version from asset_version_url.
|
||||
// The incoming request.asset_version is intentionally ignored here
|
||||
// to match Go reference behavior.
|
||||
let app_version = self.sync_context.app_version.as_ref().ok_or_else(|| {
|
||||
AssetExecutionError::MissingAppVersion {
|
||||
region: self.region_name.clone(),
|
||||
}
|
||||
})?;
|
||||
let version_url = asset_version_url.replace("{app_version}", app_version);
|
||||
let resolved_version =
|
||||
String::from_utf8_lossy(&self.get_with_retry(&version_url).await?)
|
||||
@@ -319,9 +323,13 @@ impl AssetExecutionContext {
|
||||
}
|
||||
RegionProviderConfig::Nuverse {
|
||||
asset_bundle_url_template,
|
||||
app_version,
|
||||
..
|
||||
} => {
|
||||
let app_version = self.sync_context.app_version.as_ref().ok_or_else(|| {
|
||||
AssetExecutionError::MissingAppVersion {
|
||||
region: self.region_name.clone(),
|
||||
}
|
||||
})?;
|
||||
let asset_version = self
|
||||
.resolved_asset_version
|
||||
.as_deref()
|
||||
@@ -435,6 +443,7 @@ impl AssetExecutionContext {
|
||||
&self.region,
|
||||
&temp_file,
|
||||
&task.bundle_path,
|
||||
&task.download_path,
|
||||
category,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -150,7 +150,6 @@ pub enum RegionProviderConfig {
|
||||
},
|
||||
Nuverse {
|
||||
asset_version_url: String,
|
||||
app_version: String,
|
||||
asset_info_url_template: String,
|
||||
asset_bundle_url_template: String,
|
||||
#[serde(default)]
|
||||
|
||||
@@ -107,6 +107,8 @@ pub enum AssetExecutionError {
|
||||
HttpStatus { url: String, status: u16 },
|
||||
#[error("region `{region}` is missing asset_save_dir")]
|
||||
MissingAssetSaveDir { region: String },
|
||||
#[error("nuverse region `{region}` requires asset_version and asset_hash")]
|
||||
MissingAppVersion { region: String },
|
||||
#[error("colorful_palette region `{region}` requires asset_version and asset_hash")]
|
||||
MissingAssetVersionOrHash { region: String },
|
||||
#[error("colorful_palette region `{region}` is missing profile hash for `{profile}`")]
|
||||
|
||||
@@ -54,18 +54,26 @@ pub fn get_export_group(export_path: &str) -> &'static str {
|
||||
"container"
|
||||
}
|
||||
|
||||
pub fn get_hex_index(input: &str) -> String {
|
||||
let hash_val = twox_hash::XxHash3_128::oneshot(input.as_bytes());
|
||||
format!("{:032x}", hash_val)
|
||||
}
|
||||
|
||||
pub async fn extract_unity_asset_bundle(
|
||||
app_config: &AppConfig,
|
||||
sync_context: &SyncContext,
|
||||
region: &RegionConfig,
|
||||
asset_bundle_file: &Path,
|
||||
export_path: &str,
|
||||
download_path: &str,
|
||||
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(&sync_context.region)
|
||||
.join(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));
|
||||
};
|
||||
@@ -82,7 +90,7 @@ pub async fn extract_unity_asset_bundle(
|
||||
};
|
||||
|
||||
let actual_export_path = if sync_context.export.by_category {
|
||||
output_dir.join(category.to_lowercase()).join(export_path)
|
||||
output_dir.join(category.to_lowercase())
|
||||
} else {
|
||||
output_dir.join(export_path)
|
||||
};
|
||||
@@ -126,10 +134,23 @@ pub async fn extract_unity_asset_bundle(
|
||||
.await?;
|
||||
|
||||
let mut count = 0;
|
||||
walk(&actual_export_path, &mut |_| count += 1)?;
|
||||
let mut is_bundle_name_file = true;
|
||||
let download_name = match download_path.rsplit_once("/") {
|
||||
None => download_path,
|
||||
Some((_, name)) => name,
|
||||
};
|
||||
walk(&output_dir, &mut |f| {
|
||||
count += 1;
|
||||
let file_name = f.file_name().unwrap().to_string_lossy();
|
||||
is_bundle_name_file = is_bundle_name_file
|
||||
&& match file_name.rsplit_once(".") {
|
||||
Some((name, _)) => name.eq_ignore_ascii_case(download_name),
|
||||
None => file_name.eq_ignore_ascii_case(download_name),
|
||||
}
|
||||
})?;
|
||||
|
||||
post_process_exported_files(app_config, sync_context, region, &actual_export_path).await?;
|
||||
Ok((actual_export_path, count <= 1))
|
||||
post_process_exported_files(app_config, sync_context, region, &output_dir).await?;
|
||||
Ok((output_dir, is_bundle_name_file && count <= 1))
|
||||
}
|
||||
|
||||
pub async fn post_process_exported_files(
|
||||
|
||||
Reference in New Issue
Block a user