Skip to content
Open
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
2 changes: 1 addition & 1 deletion internal/gtfs/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func rawGtfsData(ctx context.Context, source string, isLocalFile bool, config Co
// Process through gtfstidy if enabled
if config.EnableGTFSTidy {
logging.LogOperation(logger, "gtfstidy_enabled_processing_gtfs_data")
tidiedData, err := tidyGTFSData(b, logger)
tidiedData, err := tidyGTFSData(ctx, b, logger)
if err != nil {
logging.LogError(logger, "Failed to tidy GTFS data, using original data", err)
} else {
Expand Down
5 changes: 3 additions & 2 deletions internal/gtfs/tidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gtfs

import (
"bytes"
"context"
"fmt"
"log/slog"
"os"
Expand Down Expand Up @@ -51,7 +52,7 @@ func checkGTFSTidyAvailable() (string, error) {

// tidyGTFSData processes GTFS data through gtfstidy with flags -OscRCSmeD
// Returns the tidied GTFS zip data or an error
func tidyGTFSData(inputZip []byte, logger *slog.Logger) ([]byte, error) {
func tidyGTFSData(ctx context.Context, inputZip []byte, logger *slog.Logger) ([]byte, error) {
gtfstidyPath, err := checkGTFSTidyAvailable()
if err != nil {
return nil, err
Expand Down Expand Up @@ -82,7 +83,7 @@ func tidyGTFSData(inputZip []byte, logger *slog.Logger) ([]byte, error) {
slog.Int("input_size_bytes", len(inputZip)))

// -o: output file
cmd := exec.Command(gtfstidyPath, "-OscRCSmeD", "-o", outputZipPath, pristineZipPath)
cmd := exec.CommandContext(ctx, gtfstidyPath, "-OscRCSmeD", "-o", outputZipPath, pristineZipPath)
cmd.Dir = tempDir

var stdout, stderr bytes.Buffer
Expand Down
3 changes: 2 additions & 1 deletion internal/gtfs/tidy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gtfs
import (
"archive/zip"
"bytes"
"context"
"log/slog"
"os"
"path/filepath"
Expand Down Expand Up @@ -37,7 +38,7 @@ func TestTidyGTFSData(t *testing.T) {
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))

// Run tidy
outputData, err := tidyGTFSData(inputData, logger)
outputData, err := tidyGTFSData(context.Background(), inputData, logger)
if err != nil {
t.Fatalf("tidyGTFSData failed: %v", err)
}
Expand Down
Loading