diff --git a/backend/union/policy/newest.go b/backend/union/policy/newest.go index b380eaad4..c8fd4f47a 100644 --- a/backend/union/policy/newest.go +++ b/backend/union/policy/newest.go @@ -52,7 +52,8 @@ func (p *Newest) newest(ctx context.Context, upstreams []*upstream.Fs, path stri func (p *Newest) newestEntries(entries []upstream.Entry) (upstream.Entry, error) { var wg sync.WaitGroup mtimes := make([]time.Time, len(entries)) - ctx, _ := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() for i, e := range entries { wg.Add(1) i, e := i, e // Closure diff --git a/backend/union/upstream/upstream.go b/backend/union/upstream/upstream.go index ada593179..39581c3e7 100644 --- a/backend/union/upstream/upstream.go +++ b/backend/union/upstream/upstream.go @@ -307,7 +307,8 @@ func (f *Fs) updateUsageCore(lock bool) error { defer f.cacheMutex.Unlock() } // Run in background, should not be cancelled by user - ctx, _ := context.WithTimeout(context.Background(), 15*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() usage, err := f.Features().About(ctx) if err != nil { return err