s3boto _save improperly modifies content.name

Issue #194 new
Nikolas Stevenson-Molnar created an issue

The s3boto backend sets content.name = cleaned_name. This causes a problem when content is a FieldFile which gets used after the save. The following illustrates the problem:

class MyModel(models.Model):
    file = models.FileField(upload_to="/foo")

def my_method():
    my_object = MyModel.objects.get(pk=1)
    #Let's say that my_object.file.name = "/foo/bar.zip"
    default_storage.save("/foo/bar2.zip", my_object.file)
    #Now my_object.file.name = "/foo/bar2.zip"
    my_object.file.delete() #Oops! Just deleted /foo/bar2.zip, not /foo/bar.zip

As far as I can see, setting content.name isn't necessary. Could this line simply be removed?

Comments (0)

  1. Log in to comment