fix: abort when we fail to resolve CIDs
I believe we figured that these were for "informational purposes", but really, we _should_ always be able to resolve names to CIDs. If we can't, there's probably something wrong with the directory.
Steven Allen committed
Jul 30, 2021 at 11:34 UTC
66a76d27f36f202f006a6fe04809df1a3529a3be
1 file changed
+5
-4
core/corehttp/gateway_handler.go
+5
-4
@@ -391,11 +391,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
391
size = humanize.Bytes(uint64(s))
392
}
393
394
- hash := ""
395
- if r, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())); err == nil {
396
- // Path may not be resolved. Continue anyways.
397
- hash = r.Cid().String()
394
+ resolved, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name()))
395
+ if err != nil {
396
+ internalWebError(w, err)
397
+ return
398
}
399
+ hash := resolved.Cid().String()
400
401
// See comment above where originalUrlPath is declared.
402
di := directoryItem{