• W. Trevor King's avatar
    path/resolver: Fix recursive path resolution · 10669e8b
    W. Trevor King authored
    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
    10669e8b
resolver.go 3.7 KB