fix(dtmt): Fix extracting files with non-flattened file names
Fixes #51.
This commit is contained in:
parent
bdc77e70a4
commit
fb88388acf
2 changed files with 35 additions and 24 deletions
|
@ -10,6 +10,7 @@
|
||||||
=== Fixed
|
=== Fixed
|
||||||
|
|
||||||
- all: force unix path separators for engine values
|
- all: force unix path separators for engine values
|
||||||
|
- dtmt: fix extracing files with non-flattened file names
|
||||||
|
|
||||||
== 2023-03-01
|
== 2023-03-01
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use clap::{value_parser, Arg, ArgAction, ArgMatches, Command};
|
use clap::{value_parser, Arg, ArgAction, ArgMatches, Command};
|
||||||
use color_eyre::eyre::{self, Context, Result};
|
use color_eyre::eyre::{self, Context, Result};
|
||||||
use color_eyre::{Help, Report, SectionExt};
|
use color_eyre::{Help, Report};
|
||||||
use futures::future::try_join_all;
|
use futures::future::try_join_all;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use glob::Pattern;
|
use glob::Pattern;
|
||||||
|
@ -33,7 +33,7 @@ pub(crate) fn command_definition() -> Command {
|
||||||
.value_parser(value_parser!(PathBuf))
|
.value_parser(value_parser!(PathBuf))
|
||||||
.help(
|
.help(
|
||||||
"Path to the bundle(s) to read. If this points to a directory instead \
|
"Path to the bundle(s) to read. If this points to a directory instead \
|
||||||
of a file, all files in that directory will be checked.",
|
of a file, all files in that directory will be checked.",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -311,14 +311,25 @@ where
|
||||||
path.push(name);
|
path.push(name);
|
||||||
|
|
||||||
if options.dry_run {
|
if options.dry_run {
|
||||||
tracing::info!(path = %path.display(), "Writing file");
|
tracing::info!("Dry Run: Writing file '{}'", path.display());
|
||||||
} else {
|
} else {
|
||||||
tracing::debug!(path = %path.display(), "Writing file");
|
tracing::info!("Writing file '{}'", path.display());
|
||||||
tasks.push(tokio::spawn(async move {
|
tasks.push(tokio::spawn(async move {
|
||||||
fs::write(&path, file.data())
|
if let Some(parent) = path.parent() {
|
||||||
.await
|
fs::create_dir_all(&parent).await.wrap_err_with(|| {
|
||||||
.wrap_err("failed to write extracted file to disc")
|
format!(
|
||||||
.with_section(|| path.display().to_string().header("Path"))
|
"failed to create parent directories '{}'",
|
||||||
|
parent.display()
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs::write(&path, file.data()).await.wrap_err_with(|| {
|
||||||
|
format!(
|
||||||
|
"failed to write extracted file to disc: '{}'",
|
||||||
|
path.display()
|
||||||
|
)
|
||||||
|
})
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -342,9 +353,9 @@ where
|
||||||
path.push(name);
|
path.push(name);
|
||||||
|
|
||||||
if options.dry_run {
|
if options.dry_run {
|
||||||
tracing::info!(path = %path.display(), "Writing file");
|
tracing::info!("Dry Run: Writing file '{}'", path.display());
|
||||||
} else {
|
} else {
|
||||||
tracing::debug!(path = %path.display(), "Writing file");
|
tracing::info!("Writing file '{}'", path.display());
|
||||||
tasks.push(tokio::spawn(async move {
|
tasks.push(tokio::spawn(async move {
|
||||||
let parent = match path.parent() {
|
let parent = match path.parent() {
|
||||||
Some(parent) => parent,
|
Some(parent) => parent,
|
||||||
|
@ -356,17 +367,19 @@ where
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fs::create_dir_all(parent)
|
fs::create_dir_all(parent).await.wrap_err_with(|| {
|
||||||
.await
|
format!(
|
||||||
.wrap_err("failed to create parent directory")
|
"failed to create parent directory: '{}'",
|
||||||
.with_section(|| {
|
parent.display()
|
||||||
parent.display().to_string().header("Path")
|
)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
fs::write(&path, file.data())
|
fs::write(&path, file.data()).await.wrap_err_with(|| {
|
||||||
.await
|
format!(
|
||||||
.wrap_err("failed to write extracted file to disc")
|
"failed to write extracted file to disc: '{}'",
|
||||||
.with_section(|| path.display().to_string().header("Path"))
|
path.display()
|
||||||
|
)
|
||||||
|
})
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,10 +387,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let err = err
|
let err = err.wrap_err(format!("Failed to decompile file {}", name));
|
||||||
.wrap_err("Failed to decompile")
|
|
||||||
.with_section(|| name.header("File"));
|
|
||||||
|
|
||||||
tracing::error!("{:?}", err);
|
tracing::error!("{:?}", err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue