diff --git a/extern/sector-storage/stores/http_handler.go b/extern/sector-storage/stores/http_handler.go index a4c0480d4..3e3468470 100644 --- a/extern/sector-storage/stores/http_handler.go +++ b/extern/sector-storage/stores/http_handler.go @@ -116,9 +116,16 @@ func (handler *FetchHandler) remoteGetSector(w http.ResponseWriter, r *http.Requ w.WriteHeader(500) return } + if !stat.IsDir() { + defer func() { + if err := rd.(*os.File).Close(); err != nil { + log.Errorf("closing source file: %+v", err) + } + }() + } w.WriteHeader(200) - if _, err := io.Copy(w, rd); err != nil { // TODO: default 32k buf may be too small + if _, err := io.CopyBuffer(w, rd, make([]byte, CopyBuf)); err != nil { log.Errorf("%+v", err) return }