﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21057	FileSystemStorage can leave temporary files around	John Hensley	nobody	"FileSystemStorage._save doesn't close the file passed in the content argument, unless it has a 'temporary_file_path' attribute. When you upload a file bigger than FILE_UPLOAD_MAX_MEMORY_SIZE via a FileField on a ModelForm, content is its FieldFile, not the underlying NamedTemporaryFile. It doesn't have a temporary_file_path attribute, so is treated like an upload that has to be copied, not moved, and is never explicitly closed.

This is probably OK most of the time, as the NamedTemporaryFile should eventually be automatically closed and deleted. It certainly seems to be handled properly when running under the dev server. However, under uWSGI the temporary files never seem to be removed. I'm not sure yet why this is, but adding an explicit close solves the problem.

A slight improvement might be also having FieldFile pass its underlying file to the storage save() method, as then not only would the temporary file be cleaned up, but it could just be moved instead of copied, saving some work.
"	Bug	closed	File uploads/storage	1.5	Normal	fixed			Unreviewed	1	0	0	0	0	0
