Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit ae228e3

Browse files
committed
fix: folder creation when unsupported file
1 parent b18d50e commit ae228e3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/shell/command/get.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ pub fn command(state: &mut State, args: Arguments) -> Result<()> {
4343
output_dir.pop();
4444
}
4545

46-
// Create output directory
4746
debug!("Output directory: {:?}", output_dir);
48-
std::fs::create_dir_all(output_dir.clone()).unwrap();
4947

5048
// Extract the file or directory
5149
if is_file {
@@ -72,8 +70,14 @@ fn extract_file(
7270
let metadata = Metadata::from(header_file_data.clone());
7371

7472
match metadata.file_type {
75-
FileType::Audio => extract_audio(state, file_node, output_dir),
76-
FileType::Texture => extract_texture(state, file_node, output_dir),
73+
FileType::Audio => {
74+
std::fs::create_dir_all(output_dir.clone()).unwrap();
75+
extract_audio(state, file_node, output_dir)
76+
}
77+
FileType::Texture => {
78+
std::fs::create_dir_all(output_dir.clone()).unwrap();
79+
extract_texture(state, file_node, output_dir)
80+
}
7781
_ => Err(Error::msg(format!(
7882
"File is not supported: {}",
7983
file_node.borrow().name()
@@ -92,7 +96,6 @@ fn extract_dir(
9296
// Create the output directory
9397
let mut output_dir = output_dir.clone();
9498
output_dir.push(dir_node.name());
95-
std::fs::create_dir_all(output_dir.clone()).unwrap();
9699

97100
// Extract the files
98101
for file_child_node in dir_node.children_files() {

0 commit comments

Comments
 (0)