提交 1130f820 作者: Steven Allen

fix(gateway): gracefully handle files with unknown sizes in directory listings

上级 9045fc4d
...@@ -292,14 +292,14 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request ...@@ -292,14 +292,14 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
var dirListing []directoryItem var dirListing []directoryItem
dirit := dir.Entries() dirit := dir.Entries()
for dirit.Next() { for dirit.Next() {
// See comment above where originalUrlPath is declared. size := "?"
s, err := dirit.Node().Size() if s, err := dirit.Node().Size(); err == nil {
if err != nil { // Size may not be defined/supported. Continue anyways.
internalWebError(w, err) size = humanize.Bytes(uint64(s))
return
} }
di := directoryItem{humanize.Bytes(uint64(s)), dirit.Name(), gopath.Join(originalUrlPath, dirit.Name())} // See comment above where originalUrlPath is declared.
di := directoryItem{size, dirit.Name(), gopath.Join(originalUrlPath, dirit.Name())}
dirListing = append(dirListing, di) dirListing = append(dirListing, di)
} }
if dirit.Err() != nil { if dirit.Err() != nil {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论