Commit e4eb6372 authored by Peter Mrekaj's avatar Peter Mrekaj Committed by GitHub

Quick-fix unpinning error caused by a manifest serialization bug (#1628)

This quick-fix prevents the mantaray manifest IterateAddresses method
walker to fail when it encounters an empty address, otherwise, the unpin
traversal operation for the manifest fails.
parent bb4a5f52
...@@ -134,6 +134,7 @@ func (m *mantarayManifest) IterateAddresses(ctx context.Context, fn swarm.Addres ...@@ -134,6 +134,7 @@ func (m *mantarayManifest) IterateAddresses(ctx context.Context, fn swarm.Addres
return ErrMissingReference return ErrMissingReference
} }
emptyAddr := swarm.NewAddress([]byte{31: 0})
walker := func(path []byte, node *mantaray.Node, err error) error { walker := func(path []byte, node *mantaray.Node, err error) error {
if err != nil { if err != nil {
return err return err
...@@ -151,8 +152,17 @@ func (m *mantarayManifest) IterateAddresses(ctx context.Context, fn swarm.Addres ...@@ -151,8 +152,17 @@ func (m *mantarayManifest) IterateAddresses(ctx context.Context, fn swarm.Addres
if node.IsValueType() && len(node.Entry()) > 0 { if node.IsValueType() && len(node.Entry()) > 0 {
entry := swarm.NewAddress(node.Entry()) entry := swarm.NewAddress(node.Entry())
err = fn(entry) // The following comparison to the emptyAddr is
if err != nil { // a dirty hack which prevents the walker to
// fail when it encounters an empty address
// (e.g.: during the unpin traversal operation
// for manifest). This workaround should be
// removed after the manifest serialization bug
// is fixed.
if entry.Equal(emptyAddr) {
return nil
}
if err := fn(entry); err != nil {
return err return err
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment