﻿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
20355	How about pre/post_change_file signals to allow apps to delete replaced files?	pdc@…	nobody	"Some people are surprised to discover that saving a new file to a FileField does not delete the old file, and deleting a model instance does not delete its dependent files. This is for a good reason of course—I may know that user avatars are disposable, say, but Django does not. But if the app does know whether old files can e disposed of, there does not seem to be an easy way to achieve this systematically because in pre_save and post_save signal handlers we do not have acces to both the old and new path names.

Would it be easy to have a pre_change_file and post_change_file signal pair, fired during the point in saving an instance when the files are really written? Its args would be something like the following:
{{{
 sender, instance, field_name, old_path, new_path, **kwargs
}}}
where old_path is None if the file is being saved for the first time, and new_path is None if the file is being deleted (in other words, replaced with no file).

As well as enabling app-specific decisions to be me made about deleting old files, this would also be a hook to hang the recalculation of ImageField width and height attributes that would avoid recalculating them needlessly.
"	New feature	closed	File uploads/storage	1.5	Normal	wontfix			Unreviewed	0	0	0	0	0	0
