Skip to content

Commit 64369ae

Browse files
committed
log file naming consistent with output naming
1 parent bb9e88a commit 64369ae

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/analysis/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ pub fn extract_and_process(
6464

6565
let extract_dir = temp_dir.path();
6666

67-
let log_file = out_file_base.with_extension(format!("{extractor_name}.log"));
67+
let log_file = {
68+
// Simple string append to avoid with_extension() being greedy
69+
let file_name = out_file_base.file_name().unwrap().to_string_lossy();
70+
out_file_base.with_file_name(format!("{}.{extractor_name}.log", file_name))
71+
};
6872

6973
let start_time = Instant::now();
7074

@@ -96,7 +100,11 @@ pub fn extract_and_process(
96100
break;
97101
}
98102

99-
let tar_path = out_file_base.with_extension(format!("{extractor_name}.{i}.tar.gz"));
103+
let tar_path = {
104+
// Simple string append to avoid with_extension() being greedy
105+
let file_name = out_file_base.file_name().unwrap().to_string_lossy();
106+
out_file_base.with_file_name(format!("{}.{extractor_name}.{i}.tar.gz", file_name))
107+
};
100108

101109
// XXX: improve error handling here
102110
let file_node_count = tar_fs(&fs.path, &tar_path, metadata, removed_devices).unwrap();

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,13 @@ pub fn main(args: args::Args) -> Result<(BestExtractor, PathBuf), Fw2tarError> {
114114
if removed_devices.is_empty() {
115115
log::warn!("No device files were found during extraction, skipping writing log");
116116
} else {
117+
let devices_log_path = {
118+
// Simple string append to avoid with_extension() being greedy
119+
let file_name = output.file_name().unwrap().to_string_lossy();
120+
output.with_file_name(format!("{}.devices.log", file_name))
121+
};
117122
fs::write(
118-
output.with_extension("devices.log"),
123+
devices_log_path,
119124
removed_devices.join("\n"),
120125
)
121126
.unwrap();

0 commit comments

Comments
 (0)