-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
I have tracked down an issue with revel, where temporary files are leaked.
I have a controller function like this:
func (c File) Replace(id string, file io.Reader, metadata string) revel.Result {
Short story is, if I upload a file larger than 32MB, I get this error:
params.go:121: Error removing temporary files: remove c:\temp\win\multipart-265323653: The process cannot access the file, since it is in use by another process.
The reason for this is, that the file is larger than 32MB, so "req.ParseMultipartForm" in "params.go" places the file on disk. Very reasonable.
However, this also means the "io.Reader" must be closed for the system to be able to delete the file after processing it. This is not done.
So whenever Revel binds a parameter, it should check if it implements io.Closer and call it once the controller has been called.
The workarounds are:
- Test if the supplied reader is io.Closer in the controller (this should be handled by Revel)
- Use "os.File" for the controller. Silly, since that would copy it to disk every time.