Skip to content

Commit 5e65953

Browse files
committed
refactor: remove unnecessary path computation from export_to_gpx early return
IMPROVES SEPARATION OF CONCERNS - export_to_gpx() should only export data, not compute paths for messaging - Removed unnecessary path computation when gps_coordinates is empty - CLI already uses compute_export_paths() for message generation - Export functions stay focused on their core responsibility BENEFITS - Cleaner library API: export functions don't couple to CLI messaging needs - Better separation of concerns: path computation is CLI responsibility - More reusable: export functions can be used by other tools without side effects - Supports goal: Moving to shared libraries for both CLI and crate usage IMPLEMENTATION - Removed ~20 lines of path computation code from export_to_gpx early return - CLI message generation unchanged (already uses compute_export_paths) - export_to_event was already correct (had early return without path computation) VERIFICATION ✅ cargo fmt --all -- --check : PASS ✅ cargo clippy --all-targets : PASS ✅ cargo test --verbose : PASS (37 tests) ✅ cargo build --release : PASS ✅ CSV output vs master : PASS (87/87 files identical) ✅ GPX/event messaging : PASS (messages still displayed correctly) ALIGNMENT WITH GOALS ✅ De-duplication: Further reduced code duplication ✅ Shared libraries: Export functions now cleaner library APIs ✅ Better separation: Export functions don't depend on CLI messaging
1 parent 3c954cb commit 5e65953

1 file changed

Lines changed: 0 additions & 19 deletions

File tree

src/export.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -359,25 +359,6 @@ pub fn export_to_gpx(
359359
log_start_datetime: Option<&str>,
360360
) -> Result<()> {
361361
if gps_coordinates.is_empty() {
362-
// Compute path for consistency even though we're not writing anything
363-
// (allows CLI to log a consistent message)
364-
let base_name = input_path
365-
.file_stem()
366-
.and_then(|n| n.to_str())
367-
.unwrap_or("blackbox");
368-
369-
let output_dir = export_options
370-
.output_dir
371-
.as_deref()
372-
.map(Path::new)
373-
.unwrap_or_else(|| input_path.parent().unwrap_or(Path::new(".")));
374-
375-
let log_suffix = if total_logs > 1 {
376-
format!(".{:02}", log_index + 1)
377-
} else {
378-
String::new()
379-
};
380-
let _gpx_path = output_dir.join(format!("{}{}.gps.gpx", base_name, log_suffix));
381362
return Ok(());
382363
}
383364

0 commit comments

Comments
 (0)