﻿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
20660	Filefield.delete() on empty field delete MEDIA_ROOT	stanislas.guerra@…	Claude Paroz	"Maybe this is because I use a symlink in my Apache configuration to serve the media :


{{{
$ ls -l /var/www/mysite.domain.com/documents/
-rw-r--r-- 1 www-data www-data  474  1 févr. 15:27 maintenance.html
lrwxrwxrwx 1 root     root       20 26 juin  15:02 media -> /data/media_mysite
drwxr-xr-x 6 myuser www-data 4096 16 mai   12:01 static



$ ls -l /data/media_mysite
total 8
drwxrwsr-x 3 myuser www-data 4096 13 févr. 10:13 stuffs
drwxrwsr-x 3 myuser www-data 4096 13 févr. 10:00 other_stuffs

}}}

But when I call delete() on an ImageField, if that very field is empty, the symlink is wipped out!


{{{
$ python manage.py shell
In [1]: from myproject.myapp.models import MyModel
In [2]: obj = MyModel.objects.get(euid=""21439011"")
In [3]: obj.my_file
Out[3]: <FieldFile: None>
In [4]: obj.my_file.delete()


$ ls -l /var/www/mysite.domain.com/documents/
-rw-r--r-- 1 www-data www-data  474  1 févr. 15:27 maintenance.html
drwxr-xr-x 6 myproject www-data 4096 16 mai   12:01 static
}}}

Should not an exception be raised here instead ?

"	Bug	closed	File uploads/storage	dev	Normal	fixed	FileField delete		Ready for checkin	1	0	0	0	0	0
