提交 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
var dirListing []directoryItem
dirit := dir.Entries()
for dirit.Next() {
// See comment above where originalUrlPath is declared.
s, err := dirit.Node().Size()
if err != nil {
internalWebError(w, err)
return
size := "?"
if s, err := dirit.Node().Size(); err == nil {
// Size may not be defined/supported. Continue anyways.
size = humanize.Bytes(uint64(s))
}
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)
}
if dirit.Err() != nil {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论