Make sure temporary multipart files are removed from disk.
MERGE REQUEST
Overview
We noticed that temporary files with names multipart-<random_suffix>
pile up in our tmp
directory causing excessive disk usage. This is very much in line with this bug: https://github.com/golang/go/issues/20253
The solution is to manually call req.MultipartForm.RemoveAll()
in a defer
, so we clean up after each request.
To reproduce the issue:
- reduce the
req.ParseMultipartForm(32 << 20)
toreq.ParseMultipartForm(1 << 20)
(optional, you can also upload big files, I guess) - add an error to
skynetSkyfileHandlerPOST
that always happens after thedefaultPath
processing - add some delay before the error hits
- start a multipart request with Postman/curl/etc. and then cancel it
- check for multipart temp files in your tmp dir
Example for Visual Changes
Checklist
Review and complete the checklist to ensure that the MR is complete before assigned to an approver.
-
All new methods or updated methods have clear docstrings -
Testing added or updated for new methods -
Any new packages are added to Makefile and .gitlab-ci.yml -
API documentation updated for API updates -
Module README.md updated for changes to workflow -
Issue added to Sia-UI repo for new supporting features -
Changelog File Created
Issues Closed
Edited by Ivaylo Novakov