Skip to content

Commit

Permalink
fix: nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh4723 committed Sep 21, 2024
1 parent 5578e5f commit ca268d8
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions cmd/bucket-listobjects-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ func (api objectAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *http
errC error
)
listObjectsV2Cache := objectAPI.ListObjectsV2
cacheEnabled := false
if api.CacheAPI() != nil {
cacheEnabled = true
listObjectsV2Cache = api.CacheAPI().ListObjectsV2
}

Expand All @@ -348,10 +350,12 @@ func (api objectAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *http
}()
go func() {
defer wg.Done()
stc := time.Now()
listObjectsV2InfoCache, errC = listObjectsV2Cache(ctx, bucket, prefix, token, delimiter, maxKeys, fetchOwner, startAfter)
elap := time.Since(stc)
log.Println("List object cache time", elap)
if cacheEnabled {
stc := time.Now()
listObjectsV2InfoCache, errC = listObjectsV2Cache(ctx, bucket, prefix, token, delimiter, maxKeys, fetchOwner, startAfter)
elap := time.Since(stc)
log.Println("ListV2 object cache time", elap)
}
}()
wg.Wait()
}
Expand Down Expand Up @@ -462,7 +466,9 @@ func (api objectAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *http

listObjects := objectAPI.ListObjects
listObjectsCache := objectAPI.ListObjects
cacheEnabled := false
if api.CacheAPI() != nil {
cacheEnabled = true
listObjectsCache = api.CacheAPI().ListObjects
}
// Inititate a list objects operation based on the input params.
Expand All @@ -482,10 +488,12 @@ func (api objectAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *http
}()
go func() {
defer wg.Done()
stc := time.Now()
listObjectsInfoCache, errC = listObjectsCache(ctx, bucket, prefix, marker, delimiter, maxKeys)
elap := time.Since(stc)
log.Println("ListV1 object cache time", elap)
if cacheEnabled {
stc := time.Now()
listObjectsInfoCache, errC = listObjectsCache(ctx, bucket, prefix, marker, delimiter, maxKeys)
elap := time.Since(stc)
log.Println("ListV1 object cache time", elap)
}
}()

wg.Wait()
Expand Down

0 comments on commit ca268d8

Please sign in to comment.