@cryptotaxi247 / kubo / commits / 10669e8b8

path/resolver: Fix recursive path resolution

I'm not entirely clear on Go's scoping (there's some text I can't quite parse here [1]), but it seems like the := version (because this is the first time we use 'err') was masking the function-level 'nd' just for this if block. That means that after we get out of the if block and return to the start of the for-loop for the next pass, nd.Links would still be pointing at the original object's links. This commit drops the :=, which fixes the earlier: $ ipfs ls QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R/static/css Error: no link named "css" under QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R so we get the intended: $ ipfs ls QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R/static/css Qme4r3eA4h1revFBgCEv1HF1U7sLL4vvAyzRLWJhCFhwg2 7051 style.css It also means we're probably missing (or are unreliably using) a multi-level-path-resolving test. [1]: https://golang.org/ref/spec#Declarations_and_scope

W. Trevor King committed May 8, 2015 at 16:07 UTC 10669e8b8c1d44ac7510fa17947956a408a85384
1 file changed +2 -1
path/resolver.go
+2 -1
@@ -122,7 +122,8 @@ func (s *Resolver) ResolveLinks(ctx context.Context, ndd *merkledag.Node, names
122 // fetch object for link and assign to nd
123 ctx, cancel := context.WithTimeout(ctx, time.Minute)
124 defer cancel()
125 - nd, err := s.DAG.Get(ctx, next)
125 + var err error
126 + nd, err = s.DAG.Get(ctx, next)
127 if err != nil {
128 return append(result, nd), err
129 }