Skip to content

Commit 16694ed

Browse files
committed
pipeline: use path instead of filepath for cleanup operations
1 parent 9aa3323 commit 16694ed

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,6 @@ github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpx
849849
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
850850
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
851851
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
852-
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
853-
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
854852
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
855853
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
856854
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
@@ -1307,8 +1305,6 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.6
13071305
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0/go.mod h1:rg+RlpR5dKwaS95IyyZqj5Wd4E13lk/msnTS0Xl9lJM=
13081306
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU=
13091307
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ=
1310-
go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
1311-
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
13121308
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
13131309
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
13141310
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 h1:dNzwXjZKpMpE2JhmO+9HsPl42NIXFIFSUSSs0fiqra0=
@@ -1319,16 +1315,12 @@ go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0 h1:PB3Zrjs1sG1GBX
13191315
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0/go.mod h1:U2R3XyVPzn0WX7wOIypPuptulsMcPDPs/oiSVOMVnHY=
13201316
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.36.0 h1:G8Xec/SgZQricwWBJF/mHZc7A02YHedfFDENwJEdRA0=
13211317
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.36.0/go.mod h1:PD57idA/AiFD5aqoxGxCvT/ILJPeHy3MjqU/NS7KogY=
1322-
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
1323-
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
13241318
go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
13251319
go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E=
13261320
go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs=
13271321
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
13281322
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
13291323
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
1330-
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
1331-
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
13321324
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
13331325
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
13341326
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=

internal/pipeline/cleanup.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"context"
2222
"fmt"
2323
"os"
24-
"path/filepath"
24+
"path"
2525
"regexp"
2626
"time"
2727

@@ -242,7 +242,7 @@ func (cs *CleanupService) shouldDeleteDirectory(ctx context.Context, dirName str
242242

243243
// Extract just the directory name in case we got a full path
244244
// This is important for Windows compatibility where dirName might be a full path
245-
baseName := filepath.Base(dirName)
245+
baseName := path.Base(dirName)
246246

247247
// Parse timestamp from directory name
248248
// Format: <shard-name>-YYYYMMDD-HHMMSS
@@ -268,7 +268,7 @@ func (cs *CleanupService) shouldDeleteDirectory(ctx context.Context, dirName str
268268
}
269269

270270
// Check for uploaded/ subdirectory
271-
uploadedPath := filepath.Join(dirName, "uploaded")
271+
uploadedPath := path.Join(dirName, "uploaded")
272272
entries, err := cs.storage.ReadDir(uploadedPath)
273273
if err != nil {
274274
// If we can't read the uploaded directory, it might not exist

internal/pipeline/cleanup_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package pipeline
2020
import (
2121
"context"
2222
"fmt"
23-
"path/filepath"
23+
"path"
2424
"testing"
2525
"time"
2626

@@ -90,17 +90,17 @@ func TestCleanupService_shouldDeleteDirectory(t *testing.T) {
9090
newDirName := fmt.Sprintf("%s-%s", shard.Name, now.Add(-1*time.Hour).Format("20060102-150405"))
9191

9292
// Create old directory with uploaded files
93-
oldUploadedPath := filepath.Join(oldDirName, "uploaded")
93+
oldUploadedPath := path.Join(oldDirName, "uploaded")
9494
err = storage.MkdirAll(oldUploadedPath)
9595
require.NoError(t, err)
96-
err = storage.WriteFile(filepath.Join(oldUploadedPath, "test.ach"), []byte("test content"))
96+
err = storage.WriteFile(path.Join(oldUploadedPath, "test.ach"), []byte("test content"))
9797
require.NoError(t, err)
9898

9999
// Create new directory with uploaded files
100-
newUploadedPath := filepath.Join(newDirName, "uploaded")
100+
newUploadedPath := path.Join(newDirName, "uploaded")
101101
err = storage.MkdirAll(newUploadedPath)
102102
require.NoError(t, err)
103-
err = storage.WriteFile(filepath.Join(newUploadedPath, "test.ach"), []byte("test content"))
103+
err = storage.WriteFile(path.Join(newUploadedPath, "test.ach"), []byte("test content"))
104104
require.NoError(t, err)
105105

106106
// Create directory without uploaded subdirectory (use different timestamp to avoid conflict)
@@ -154,26 +154,26 @@ func TestCleanupService_runCleanup(t *testing.T) {
154154
// Create directories to test
155155
// 1. Old directory with uploaded files (should be deleted)
156156
oldDir1 := fmt.Sprintf("%s-%s", shard.Name, now.Add(-48*time.Hour).Format("20060102-150405"))
157-
oldUploadedPath1 := filepath.Join(oldDir1, "uploaded")
157+
oldUploadedPath1 := path.Join(oldDir1, "uploaded")
158158
err = storage.MkdirAll(oldUploadedPath1)
159159
require.NoError(t, err)
160-
err = storage.WriteFile(filepath.Join(oldUploadedPath1, "test1.ach"), []byte("test content 1"))
160+
err = storage.WriteFile(path.Join(oldUploadedPath1, "test1.ach"), []byte("test content 1"))
161161
require.NoError(t, err)
162162

163163
// 2. Another old directory with uploaded files (should be deleted)
164164
oldDir2 := fmt.Sprintf("%s-%s", shard.Name, now.Add(-72*time.Hour).Format("20060102-150405"))
165-
oldUploadedPath2 := filepath.Join(oldDir2, "uploaded")
165+
oldUploadedPath2 := path.Join(oldDir2, "uploaded")
166166
err = storage.MkdirAll(oldUploadedPath2)
167167
require.NoError(t, err)
168-
err = storage.WriteFile(filepath.Join(oldUploadedPath2, "test2.ach"), []byte("test content 2"))
168+
err = storage.WriteFile(path.Join(oldUploadedPath2, "test2.ach"), []byte("test content 2"))
169169
require.NoError(t, err)
170170

171171
// 3. New directory (should not be deleted)
172172
newDir := fmt.Sprintf("%s-%s", shard.Name, now.Add(-1*time.Hour).Format("20060102-150405"))
173-
newUploadedPath := filepath.Join(newDir, "uploaded")
173+
newUploadedPath := path.Join(newDir, "uploaded")
174174
err = storage.MkdirAll(newUploadedPath)
175175
require.NoError(t, err)
176-
err = storage.WriteFile(filepath.Join(newUploadedPath, "test3.ach"), []byte("test content 3"))
176+
err = storage.WriteFile(path.Join(newUploadedPath, "test3.ach"), []byte("test content 3"))
177177
require.NoError(t, err)
178178

179179
// 4. Old directory without uploaded files (should not be deleted)
@@ -237,10 +237,10 @@ func TestCleanupService_GetStats(t *testing.T) {
237237
// Create test directories
238238
// Old directory eligible for deletion
239239
oldDir := fmt.Sprintf("%s-%s", shard.Name, now.Add(-48*time.Hour).Format("20060102-150405"))
240-
oldUploadedPath := filepath.Join(oldDir, "uploaded")
240+
oldUploadedPath := path.Join(oldDir, "uploaded")
241241
err = storage.MkdirAll(oldUploadedPath)
242242
require.NoError(t, err)
243-
err = storage.WriteFile(filepath.Join(oldUploadedPath, "test.ach"), []byte("test content"))
243+
err = storage.WriteFile(path.Join(oldUploadedPath, "test.ach"), []byte("test content"))
244244
require.NoError(t, err)
245245

246246
// New directory not eligible

0 commit comments

Comments
 (0)