Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ pub fn extract_and_process(

let extract_dir = temp_dir.path();

let log_file = out_file_base.with_extension(format!("{extractor_name}.log"));
let log_file = {
// Simple string append to avoid with_extension() being greedy
let file_name = out_file_base.file_name().unwrap().to_string_lossy();
out_file_base.with_file_name(format!("{}.{extractor_name}.log", file_name))
};

let start_time = Instant::now();

Expand Down Expand Up @@ -96,7 +100,11 @@ pub fn extract_and_process(
break;
}

let tar_path = out_file_base.with_extension(format!("{extractor_name}.{i}.tar.gz"));
let tar_path = {
// Simple string append to avoid with_extension() being greedy
let file_name = out_file_base.file_name().unwrap().to_string_lossy();
out_file_base.with_file_name(format!("{}.{extractor_name}.{i}.tar.gz", file_name))
};

// XXX: improve error handling here
let file_node_count = tar_fs(&fs.path, &tar_path, metadata, removed_devices).unwrap();
Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,13 @@ pub fn main(args: args::Args) -> Result<(BestExtractor, PathBuf), Fw2tarError> {
if removed_devices.is_empty() {
log::warn!("No device files were found during extraction, skipping writing log");
} else {
let devices_log_path = {
// Simple string append to avoid with_extension() being greedy
let file_name = output.file_name().unwrap().to_string_lossy();
output.with_file_name(format!("{}.devices.log", file_name))
};
fs::write(
output.with_extension("devices.log"),
devices_log_path,
removed_devices.join("\n"),
)
.unwrap();
Expand Down