mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 02:47:48 +08:00
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
This commit is contained in:
parent
cd37b6741d
commit
10669e8b8c
@ -122,7 +122,8 @@ func (s *Resolver) ResolveLinks(ctx context.Context, ndd *merkledag.Node, names
|
||||
// fetch object for link and assign to nd
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||
defer cancel()
|
||||
nd, err := s.DAG.Get(ctx, next)
|
||||
var err error
|
||||
nd, err = s.DAG.Get(ctx, next)
|
||||
if err != nil {
|
||||
return append(result, nd), err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user