Skip to content

Commit

Permalink
tweak listFiles perf by asking for specific fields
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Nov 27, 2024
1 parent 83a6c53 commit dad1c47
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/purger/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ func listFiles(ctx context.Context, prefix string, bucket *storage.BucketHandle,
defer cancel()

zlog.Info("Listing files from bucket", zap.String("prefix", prefix))
it := bucket.Objects(ctx, &storage.Query{
q := &storage.Query{
Prefix: prefix,
})
}
q.SetAttrSelection([]string{"Name", "Created", "Size"})
it := bucket.Objects(ctx, q)

count := 0
for {
Expand All @@ -46,7 +48,7 @@ func listFiles(ctx context.Context, prefix string, bucket *storage.BucketHandle,
return nil
}

func worker(ctx context.Context, id int, wg *sync.WaitGroup, jobs <-chan job) {
func worker(ctx context.Context, wg *sync.WaitGroup, jobs <-chan job) {
defer wg.Done()
for j := range jobs {
err := deleteFile(ctx, j.filePath, j.bucket)
Expand Down

0 comments on commit dad1c47

Please sign in to comment.