diff --git a/pkg/local_object_storage/shard/dump.go b/pkg/local_object_storage/shard/dump.go index 667a72ec..4f39366e 100644 --- a/pkg/local_object_storage/shard/dump.go +++ b/pkg/local_object_storage/shard/dump.go @@ -81,7 +81,10 @@ func (s *Shard) Dump(prm *DumpPrm) (*DumpRes, error) { var count int if s.hasWriteCache() { - err := s.writeCache.Iterate(new(writecache.IterationPrm).WithHandler(func(data []byte) error { + var iterPrm writecache.IterationPrm + + iterPrm.WithIgnoreErrors(prm.ignoreErrors) + iterPrm.WithHandler(func(data []byte) error { var size [4]byte binary.LittleEndian.PutUint32(size[:], uint32(len(data))) if _, err := w.Write(size[:]); err != nil { @@ -94,7 +97,9 @@ func (s *Shard) Dump(prm *DumpPrm) (*DumpRes, error) { count++ return nil - }).WithIgnoreErrors(prm.ignoreErrors)) + }) + + err := s.writeCache.Iterate(iterPrm) if err != nil { return nil, err } diff --git a/pkg/local_object_storage/writecache/iterate.go b/pkg/local_object_storage/writecache/iterate.go index a1e59837..9b810b51 100644 --- a/pkg/local_object_storage/writecache/iterate.go +++ b/pkg/local_object_storage/writecache/iterate.go @@ -19,21 +19,19 @@ type IterationPrm struct { } // WithHandler sets a callback to be executed on every object. -func (p *IterationPrm) WithHandler(f func([]byte) error) *IterationPrm { +func (p *IterationPrm) WithHandler(f func([]byte) error) { p.handler = f - return p } // WithIgnoreErrors sets a flag indicating that errors should be ignored. -func (p *IterationPrm) WithIgnoreErrors(ignore bool) *IterationPrm { +func (p *IterationPrm) WithIgnoreErrors(ignore bool) { p.ignoreErrors = ignore - return p } // Iterate iterates over all objects present in write cache. // This is very difficult to do correctly unless write-cache is put in read-only mode. // Thus we silently fail if shard is not in read-only mode to avoid reporting misleading results. -func (c *cache) Iterate(prm *IterationPrm) error { +func (c *cache) Iterate(prm IterationPrm) error { c.modeMtx.RLock() defer c.modeMtx.RUnlock() if !c.readOnly() { diff --git a/pkg/local_object_storage/writecache/writecache.go b/pkg/local_object_storage/writecache/writecache.go index e28b8bf9..59826370 100644 --- a/pkg/local_object_storage/writecache/writecache.go +++ b/pkg/local_object_storage/writecache/writecache.go @@ -20,7 +20,7 @@ type Cache interface { Get(address oid.Address) (*object.Object, error) Head(oid.Address) (*object.Object, error) Delete(oid.Address) error - Iterate(*IterationPrm) error + Iterate(IterationPrm) error Put(*object.Object) error SetMode(Mode) DumpInfo() Info