mirror of
https://github.com/xavo95/repak.git
synced 2025-01-18 10:54:38 +00:00
Fix incorrect unpack output directory default
This commit is contained in:
parent
898be58855
commit
b1cfe4aa1f
1 changed files with 6 additions and 10 deletions
|
@ -137,15 +137,11 @@ fn unpack(args: ActionUnpack) -> Result<(), unpak::Error> {
|
|||
BufReader::new(File::open(&args.input)?),
|
||||
args.aes_key.map(|k| aes_key(k.as_str())).transpose()?,
|
||||
)?;
|
||||
let output = args.output.as_ref().map(Path::new).unwrap_or_else(|| {
|
||||
Path::new(
|
||||
Path::new(&args.input)
|
||||
.file_stem()
|
||||
.and_then(|name| name.to_str())
|
||||
.expect("could not get pak file name"),
|
||||
)
|
||||
});
|
||||
match fs::create_dir(output) {
|
||||
let output = args
|
||||
.output
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| Path::new(&args.input).with_extension(""));
|
||||
match fs::create_dir(&output) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(ref e) if e.kind() == std::io::ErrorKind::AlreadyExists => Ok(()),
|
||||
Err(e) => Err(e),
|
||||
|
@ -165,7 +161,7 @@ fn unpack(args: ActionUnpack) -> Result<(), unpak::Error> {
|
|||
.strip_prefix(prefix)
|
||||
.map_err(|_| unpak::Error::Other("prefix does not match"))?,
|
||||
);
|
||||
if !file_path.clean().starts_with(output) {
|
||||
if !file_path.clean().starts_with(&output) {
|
||||
return Err(unpak::Error::Other(
|
||||
"tried to write file outside of output directory",
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue