Fix append (#43)

* fix(fs/local): remove O_APPEND for write_at

* fix(files): clean download api

* chore(workflows): add manual dispatch for docker

* test(files): close fd in the progress of uploading
This commit is contained in:
Hexxa 2021-03-19 23:00:22 +08:00 committed by GitHub
parent 9b2157ac6a
commit a9ccb4506c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 11 deletions

View file

@ -394,8 +394,7 @@ func (h *FileHandlers) Download(c *gin.Context) {
c.JSON(q.ErrResp(c, 500, err))
return
}
// defer r.Close()
// := r.(*os.File)
// reader will be closed by multipart response writer
// respond to normal requests
if ifRangeVal != "" || rangeVal == "" {
@ -410,7 +409,6 @@ func (h *FileHandlers) Download(c *gin.Context) {
return
}
// pr, pw := io.Pipe()
mw, contentLength, err := multipart.NewResponseWriter(r, parts, false)
if err != nil {
c.JSON(q.ErrResp(c, 500, err))
@ -418,14 +416,9 @@ func (h *FileHandlers) Download(c *gin.Context) {
}
go mw.Write()
// WriteResponse(r, pw, filePath, parts)
// if err != nil {
// c.JSON(q.ErrResp(c, 500, err))
// return
// }
extraHeaders := map[string]string{
// "Content-Disposition": fmt.Sprintf(`attachment; filename="%s"`, filePath),
"Content-Disposition": fmt.Sprintf(`attachment; filename="%s"`, info.Name()),
}
// it takes the \r\n before body into account, so contentLength+2
c.DataFromReader(206, contentLength+2, contentType, mw, extraHeaders)