Update the upload length in FileInfo when it's sent

This commit is contained in:
Adam Jensen 2018-04-23 17:16:20 -04:00
parent c94e0cd0b6
commit 64c02a9de1
1 changed files with 11 additions and 0 deletions

View File

@ -456,6 +456,17 @@ func (handler *UnroutedHandler) PatchFile(w http.ResponseWriter, r *http.Request
return return
} }
if info.SizeIsDeferred && r.Header.Get("Upload-Length") != "" {
uploadLength, err := strconv.ParseInt(r.Header.Get("Upload-Length"), 10, 64)
if err != nil || uploadLength < 0 {
handler.sendError(w, r, ErrInvalidOffset)
return
}
info.Size = uploadLength
info.SizeIsDeferred = false
}
if err := handler.writeChunk(id, info, w, r); err != nil { if err := handler.writeChunk(id, info, w, r); err != nil {
handler.sendError(w, r, err) handler.sendError(w, r, err)
return return