Skip to content

Commit

Permalink
Add comment about copying context
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Oct 26, 2021
1 parent 0cfacfd commit 4d4753b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/http/services/owncloud/ocs/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func (s *svc) cacheWarmup(w http.ResponseWriter, r *http.Request) {
tkn := ctxpkg.ContextMustGetToken(r.Context())
log := appctx.GetLogger(r.Context())

// We make a copy of the context because the original one comes with
// its context channel, so once the initial request is finished, this ctx gets cancelled as well.
// And in most of the cases, it takes a longer amount of time to complete than the original request.
// TODO: Check if we can come up with a better solution, eg, https://stackoverflow.com/a/54132324
ctx := context.Background()
ctx = appctx.WithLogger(ctx, log)
ctx = ctxpkg.ContextSetUser(ctx, u)
Expand Down

0 comments on commit 4d4753b

Please sign in to comment.