aaugustin/django-resto — Issue #1: DistributedStorageMixin.exists() is called twice
Author: max-arnold
Created: 2012-01-29 17:26:14+00:00
State: open

HEAD request is sent twice to webdav server upon file upload. I believe this is due to DistributedStorageMixin._save method:

def _save(self, name, content):
# This is really prone to race conditions - see README.
name = self.get_available_name(name)
DistributedStorageMixin._save(self, name, content)
return name

The line "name = self.get_available_name(name)" is probably not necessary, because django default Storage.save() method already calls it (https://docs.djangoproject.com/en/1.3/howto/custom-file-storage/#save-name-content ):

def save(self, name, content):
"""
Saves new content to the file specified by name. The content should be a
proper File object, ready to be read from the beginning.
"""
# Get the proper name for the file, as it will actually be saved.
if name is None:
name = content.name

name = self.get_available_name(name)
name = self._save(name, content)

# Store filenames with forward slashes, even on Windows
return force_unicode(name.replace('\\', '/'))

Is this a bug?