The walkfetch logic in httpsync used named return variables. It then
used a defer function to call the block hook with synced CIDs when the
return err variable is nil and there is a blockhook.
The issue was that the error variable was not being set in some of the
execution paths. It was also shadowed internally by the read-opener
which made the implementation error prone.
The fix here avoids all of that by removing the named return variables,
and explicitly returning the list of synced CIDs which are then passed
onto the block hook if there is no error returned. That change
guarantees that blockhook will never be called if an error occurs during
walkfetch and makes the implementation less prone to accidental
shadowing of named return variables.
The walkfetch logic in httpsync used named return variables. It then used a
defer
function to call the block hook with synced CIDs when the returnerr
variable is nil and there is a blockhook.The issue was that the error variable was not being set in some of the execution paths. It was also shadowed internally by the read-opener which made the implementation error prone.
The fix here avoids all of that by removing the named return variables, and explicitly returning the list of synced CIDs which are then passed onto the block hook if there is no error returned. That change guarantees that blockhook will never be called if an error occurs during walkfetch and makes the implementation less prone to accidental shadowing of named return variables.