Skip to content

Commit

Permalink
fix: remove tmp multipart files (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolesnikovae authored Nov 4, 2022
1 parent 508466e commit 6a1b631
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/convert/jfr/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func loadJFRFromForm(r io.Reader, contentType string) (io.Reader, *LabelsSnapsho
if err != nil {
return nil, nil, err
}
defer func() {
_ = f.RemoveAll()
}()

jfrField, err := form.ReadField(f, "jfr")
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/convert/pprof/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ func (p *RawProfile) loadPprofFromForm() error {
return err
}

// maxMemory 32MB.
// TODO(kolesnikovae): If the limit is exceeded, parts will be written
// to disk. It may be better to limit the request body size to be sure
// that they loaded into memory entirely.
f, err := multipart.NewReader(bytes.NewReader(p.RawData), boundary).ReadForm(32 << 20)
if err != nil {
return err
}
defer func() {
_ = f.RemoveAll()
}()

p.Profile, err = form.ReadField(f, formFieldProfile)
if err != nil {
return err
Expand Down

0 comments on commit 6a1b631

Please sign in to comment.