Skip to content

Commit

Permalink
Fix loop iterator bug (#67)
Browse files Browse the repository at this point in the history
The closure in the cleaner improperly references a loop iterator.  While
this does not cause functional problems, the output becomes duplicated.
  • Loading branch information
maguro committed Jan 11, 2022
1 parent c961632 commit 834f5cb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/gcrcleaner/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ func (c *Cleaner) Clean(repo string, since time.Time, keep int, tagFilter TagFil
deletedLock.Unlock()
}

ref := gcrrepo.Digest(m.Digest)
digest := m.Digest
ref := gcrrepo.Digest(digest)
pool.Submit(func() {
// Do not process if previous invocations failed. This prevents a large
// build-up of failed requests and rate limit exceeding (e.g. bad auth).
Expand All @@ -125,7 +126,7 @@ func (c *Cleaner) Clean(repo string, since time.Time, keep int, tagFilter TagFil
}

deletedLock.Lock()
deleted = append(deleted, m.Digest)
deleted = append(deleted, digest)
deletedLock.Unlock()
})
}
Expand Down

0 comments on commit 834f5cb

Please sign in to comment.