From b2272fef3a6b0d50775074257edee5d2d5d7dc8d Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Wed, 18 Aug 2021 19:36:47 +0200 Subject: [PATCH] delete overflowing blobs from underlying cache --- store/gcache.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/store/gcache.go b/store/gcache.go index 03e2829..f21ed8d 100644 --- a/store/gcache.go +++ b/store/gcache.go @@ -144,11 +144,15 @@ func (l *GcacheStore) loadExisting(store lister, maxItems int) error { logrus.Infof("read %d files from underlying store", len(existing)) added := 0 - for _, h := range existing { + for i, h := range existing { _ = l.cache.Set(h, true) added++ if maxItems > 0 && added >= maxItems { // underlying cache is bigger than the cache - break + err := l.Delete(h) + logrus.Infof("deleted overflowing blob: %s (%d/%d)", h, i, len(existing)) + if err != nil { + logrus.Warnf("error while deleting a blob that's overflowing the cache: %s", err.Error()) + } } } return nil