{{{
$ 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 ?
--
Ticket URL: <https://code.djangoproject.com/ticket/20660>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
I should have mention that MEDIA_ROOT is not deleted (only the symlink
is.)
--
Ticket URL: <https://code.djangoproject.com/ticket/20660#comment:1>
* version: 1.4 => master
* stage: Unreviewed => Accepted
Comment:
I could reproduce this. And yes, the deletion succeeds only when
MEDIA_ROOT is a symlink (when it's a real directory, it will fail with
`OSError: [Errno 21] Is a directory: ...` at least on Linux).
I tend to think there are two bugs:
* `FieldFile` should not call `storage.delete` when `self._file` is None
* `FileSystemStorage` should not try to remove a path when its `delete`
method receives `''` as argument.
--
Ticket URL: <https://code.djangoproject.com/ticket/20660#comment:2>
* status: new => assigned
* owner: nobody => claudep
--
Ticket URL: <https://code.djangoproject.com/ticket/20660#comment:3>
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/1310
--
Ticket URL: <https://code.djangoproject.com/ticket/20660#comment:4>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/20660#comment:5>
Comment (by Claude Paroz <claude@…>):
In [changeset:"7fbab3ebaf8b60bbe847b772f895df47067a60d3"]:
{{{
#!CommitTicketReference repository=""
revision="7fbab3ebaf8b60bbe847b772f895df47067a60d3"
Do not allow FileSystemStorage.delete to receive an empty name
Refs #20660.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20660#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"ea3fe78a9d742904f6902cdc353a11d795418105"]:
{{{
#!CommitTicketReference repository=""
revision="ea3fe78a9d742904f6902cdc353a11d795418105"
Fixed #20660 -- Do not try to delete an unset FieldFile
Thanks stanislas.guerra at gmail.com for the report and
Baptiste Mispelon for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20660#comment:6>
Comment (by Claude Paroz <claude@…>):
In [changeset:"a9b5a1e506a9e8492407399b8bec1c2a8420be60"]:
{{{
#!CommitTicketReference repository=""
revision="a9b5a1e506a9e8492407399b8bec1c2a8420be60"
[1.6.x] Do not allow FileSystemStorage.delete to receive an empty name
Refs #20660.
Backport of 7fbab3eba from master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20660#comment:9>
Comment (by Claude Paroz <claude@…>):
In [changeset:"b6aed803b20cc7898a82fd65845e97676276f3fa"]:
{{{
#!CommitTicketReference repository=""
revision="b6aed803b20cc7898a82fd65845e97676276f3fa"
[1.6.x] Fixed #20660 -- Do not try to delete an unset FieldFile
Thanks stanislas.guerra at gmail.com for the report and
Baptiste Mispelon for the review.
Backport of ea3fe78a9d from master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20660#comment:8>