﻿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
6456	FileField deletes files even when model instance is deleted in a transaction that is rolled back	durdinator	nobody	"I've got a model with a few FileFields.  I've got code resembling this:

{{{

class SomeObject(models.Model):
    ...

class RelatedFile(models.Model):
    filename = models.FileField(...)
    owner = models.ForeignKey(SomeObject, related_name='related_files')

@commit_on_success
def update_files(request, id):
    obj = get_object_or_404(SomeObject, pk=id)
    obj.related_files.all().delete()
    ... more code - which depending on external conditions can raise an exception ...
}}}

Since the FileField hooks the RelatedFile's post_delete signal, it deletes the original files when the delete() method is called.  Then if the transaction is rolled back, the rows in the database, not being deleted after all, point to nonexistent files.


"		closed	File uploads/storage	dev		fixed			Accepted	0	1	0	0	0	0
