From 75cc6df58649b5e877baba094bbb1072a221c667 Mon Sep 17 00:00:00 2001 From: darkweak Date: Sun, 8 Dec 2024 12:51:30 +0100 Subject: [PATCH] fix(ci): golangci --- core/registered.go | 2 +- simplefs/simplefs.go | 23 +++++++++++------------ simplefs/simplefs_test.go | 4 ++-- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/core/registered.go b/core/registered.go index de89a09..e0678df 100644 --- a/core/registered.go +++ b/core/registered.go @@ -8,7 +8,7 @@ import ( var registered = sync.Map{} func RegisterStorage(s Storer) { - s.Init() + _ = s.Init() registered.Store(fmt.Sprintf("%s-%s", s.Name(), s.Uuid()), s) } diff --git a/simplefs/simplefs.go b/simplefs/simplefs.go index e479ed0..a9217c7 100644 --- a/simplefs/simplefs.go +++ b/simplefs/simplefs.go @@ -176,6 +176,7 @@ func (provider *Simplefs) recoverEnoughSpaceIfNeeded(size int64) { if provider.directorySize > -1 && provider.actualSize+size > provider.directorySize { provider.cache.RangeBackwards(func(item *ttlcache.Item[string, []byte]) bool { // Remove the oldest item if there is not enough space. + //nolint:godox // TODO: open a PR to expose a range that iterate on LRU items. provider.cache.Delete(string(item.Value())) @@ -184,8 +185,6 @@ func (provider *Simplefs) recoverEnoughSpaceIfNeeded(size int64) { provider.recoverEnoughSpaceIfNeeded(size) } - - return } // SetMultiLevel tries to store the key with the given value and update the mapping key to store metadata. @@ -267,14 +266,14 @@ func (provider *Simplefs) DeleteMany(key string) { // Init method will. func (provider *Simplefs) Init() error { - provider.cache.OnInsertion(func(_ context.Context, i *ttlcache.Item[string, []byte]) { - if strings.Contains(string(i.Key()), core.MappingKeyPrefix) { + provider.cache.OnInsertion(func(_ context.Context, item *ttlcache.Item[string, []byte]) { + if strings.Contains(item.Key(), core.MappingKeyPrefix) { return } - info, err := os.Stat(string(i.Value())) + info, err := os.Stat(string(item.Value())) if err != nil { - provider.logger.Errorf("impossible to get the file size %s: %#v", i.Key(), err) + provider.logger.Errorf("impossible to get the file size %s: %#v", item.Key(), err) return } @@ -285,14 +284,14 @@ func (provider *Simplefs) Init() error { provider.mu.Unlock() }) - provider.cache.OnEviction(func(_ context.Context, _ ttlcache.EvictionReason, i *ttlcache.Item[string, []byte]) { - if strings.Contains(string(i.Value()), core.MappingKeyPrefix) { + provider.cache.OnEviction(func(_ context.Context, _ ttlcache.EvictionReason, item *ttlcache.Item[string, []byte]) { + if strings.Contains(string(item.Value()), core.MappingKeyPrefix) { return } - info, err := os.Stat(string(i.Value())) + info, err := os.Stat(string(item.Value())) if err != nil { - provider.logger.Errorf("impossible to get the file size %s: %#v", i.Key(), err) + provider.logger.Errorf("impossible to get the file size %s: %#v", item.Key(), err) return } @@ -302,8 +301,8 @@ func (provider *Simplefs) Init() error { provider.logger.Debugf("Actual size remove: %d", provider.actualSize, info.Size()) provider.mu.Unlock() - if err := onEvict(string(i.Value())); err != nil { - provider.logger.Errorf("impossible to remove the file %s: %#v", i.Key(), err) + if err := onEvict(string(item.Value())); err != nil { + provider.logger.Errorf("impossible to remove the file %s: %#v", item.Key(), err) } }) diff --git a/simplefs/simplefs_test.go b/simplefs/simplefs_test.go index 5ba5552..40bcf09 100644 --- a/simplefs/simplefs_test.go +++ b/simplefs/simplefs_test.go @@ -138,9 +138,9 @@ func TestSimplefs_Init(t *testing.T) { func TestSimplefs_EvictAfterXSeconds(t *testing.T) { client, _ := getSimplefsInstance() - client.Init() + _ = client.Init() - for i := 0; i < 10; i++ { + for i := range 10 { key := fmt.Sprintf("Test_%d", i) _ = client.SetMultiLevel(key, key, []byte(baseValue), http.Header{}, "", 1*time.Second, key) }