--
Ticket URL: <https://code.djangoproject.com/ticket/17812>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* component: Uncategorized => File uploads/storage
* needs_tests: => 0
* needs_better_patch: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/17812#comment:1>
* status: new => closed
* resolution: => worksforme
Comment:
Here's what I understand from your report (I see you aren't a native
speaker):
- `settings.MEDIA_ROOT` is a symlink — for instance, `/var/www/media ->
/mnt/storage/media`
- you save a model that has an `ImageField`, without providing any value —
`instance = MyModel.objects.get(pk=1); instance.my_image = None;
instance.save()`
- the symlink gets deleted
I tried that, and I can't reproduce the problem. To be honest, it sounds
extremely unlikely that Django would delete a directory or a symlink like
that.
--
Ticket URL: <https://code.djangoproject.com/ticket/17812#comment:2>
* status: closed => reopened
* resolution: worksforme =>
Comment:
It's happening when I try to delete image by {{{ image.delete() }}}
method.
It's better to show by an example.
Suppose for example we have some model:
{{{
class Image(models.Model):
image = models.ImageField()
class Meta:
app_label = 'image'
}}}
Then we try to do following:
{{{
image = Image()
image.image.delete()
}}}
Thereafter symlink to media files will be deleted.
Also I was mistaken about the {{{ FileField }}}: This is happening for it
too.
Apparently this is happening because the name of image field {{{
image.image.name }}} is a blank string {{{ '' }}}.
Therefore {{{ FileSystemStorage.delete }}} method gets path to media
symlink and deletes it.
--
Ticket URL: <https://code.djangoproject.com/ticket/17812#comment:3>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/17812#comment:4>
* needs_tests: 0 => 1
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/17812#comment:5>
* status: new => closed
* resolution: => fixed
Comment:
It looks like ea3fe78a9d742904f6902cdc353a11d795418105 will prevent this.
--
Ticket URL: <https://code.djangoproject.com/ticket/17812#comment:7>