make sure path is normalized on first save

This commit is contained in:
j 2014-03-12 20:23:59 +01:00
parent 8d96cd80ce
commit ad89e9ffed

View file

@ -226,8 +226,12 @@ class File(models.Model):
self.parse_info()
def save(self, *args, **kwargs):
if self.id and self.info:
update_path = False
if self.info:
if self.id:
self.path = self.normalize_path()
else:
update_path = True
if self.item:
data = self.get_path_info()
self.extension = data.get('extension')
@ -257,6 +261,9 @@ class File(models.Model):
self.available = not self.uploading and \
self.streams.filter(source=None, available=True).count() > 0
super(File, self).save(*args, **kwargs)
if update_path:
self.path = self.normalize_path()
super(File, self).save(*args, **kwargs)
def get_path(self, name):
h = self.oshash