Skip to content

Commit 04eb9d1

Browse files
committed
backends/s3: more consistent location for clientTimeoutContext in List
1 parent e6bc4aa commit 04eb9d1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

backends/s3/s3.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ func (b *Backend) List(ctx context.Context, prefix string) (blobList simpleblob.
203203
combinedPrefix := b.prependGlobalPrefix(prefix)
204204

205205
if !b.opt.UseUpdateMarker {
206+
ctx, cancel := b.clientTimeoutContext(ctx)
207+
defer cancel()
208+
206209
return b.doList(ctx, combinedPrefix)
207210
}
208211

@@ -227,6 +230,9 @@ func (b *Backend) List(ctx context.Context, prefix string) (blobList simpleblob.
227230
return blobs.WithPrefix(prefix), nil
228231
}
229232

233+
ctx, cancel := b.clientTimeoutContext(ctx)
234+
defer cancel()
235+
230236
blobs, err = b.doList(ctx, b.opt.GlobalPrefix) // We want to cache all, so no prefix
231237
if err != nil {
232238
return nil, err
@@ -249,8 +255,6 @@ func recordMinioDurationMetric(method string, start time.Time) {
249255
func (b *Backend) doList(ctx context.Context, prefix string) (blobs simpleblob.BlobList, err error) {
250256
metricCalls.WithLabelValues("list").Inc()
251257
metricLastCallTimestamp.WithLabelValues("list").SetToCurrentTime()
252-
ctx, cancel := b.clientTimeoutContext(ctx)
253-
defer cancel()
254258
defer recordMinioDurationMetric("list", time.Now())
255259

256260
// Runes to strip from blob names for GlobalPrefix

0 commit comments

Comments
 (0)