Technical Follow-ups for src/export.rs
1. Missing directory creation in GPX export
Issue: export_to_gpx doesn't call std::fs::create_dir_all(output_dir) like export_to_csv does, causing failures when exporting only GPX to a non-existent directory.
Current behavior: If a caller sets export_options.output_dir to a non-existent directory and only requests GPX export (no CSV), the export will fail with ENOENT.
Expected behavior: Should mirror the CSV behavior by creating the output directory if it doesn't exist.
Suggested fix:
let output_dir = export_options
.output_dir
.as_deref()
.map(Path::new)
.unwrap_or_else(|| input_path.parent().unwrap_or(Path::new(".")));
// Ensure output directory exists (match export_to_csv behavior)
if !output_dir.exists() {
std::fs::create_dir_all(output_dir)?;
}
2. Optional code reuse opportunity
Suggestion: Now that compute_export_paths exists and encodes the canonical naming scheme (including the .NN suffix and .gps.gpx extension), consider avoiding duplicating the suffix logic in export_to_gpx by:
- Passing a 1-based
log_number instead of log_index and total_logs
- Using the
gpx_path from compute_export_paths instead of recomputing gpx_filename
This would keep naming and CLI status messages in lockstep with the actual GPX file path.
Location: src/export.rs lines 337-419 (export_to_gpx function)
Priority: Issue #1 is a bug fix, Issue #2 is a refactoring/DRY improvement
Technical Follow-ups for
src/export.rs1. Missing directory creation in GPX export
Issue:
export_to_gpxdoesn't callstd::fs::create_dir_all(output_dir)likeexport_to_csvdoes, causing failures when exporting only GPX to a non-existent directory.Current behavior: If a caller sets
export_options.output_dirto a non-existent directory and only requests GPX export (no CSV), the export will fail withENOENT.Expected behavior: Should mirror the CSV behavior by creating the output directory if it doesn't exist.
Suggested fix:
2. Optional code reuse opportunity
Suggestion: Now that
compute_export_pathsexists and encodes the canonical naming scheme (including the.NNsuffix and.gps.gpxextension), consider avoiding duplicating the suffix logic inexport_to_gpxby:log_numberinstead oflog_indexandtotal_logsgpx_pathfromcompute_export_pathsinstead of recomputinggpx_filenameThis would keep naming and CLI status messages in lockstep with the actual GPX file path.
Location:
src/export.rslines 337-419 (export_to_gpxfunction)Priority: Issue #1 is a bug fix, Issue #2 is a refactoring/DRY improvement