From ad89e9ffede1c88b1118f964a41125cda478aa1b Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 12 Mar 2014 20:23:59 +0100 Subject: [PATCH] make sure path is normalized on first save --- pandora/archive/models.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index d8521e2ea..e2d05387b 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -226,8 +226,12 @@ class File(models.Model): self.parse_info() def save(self, *args, **kwargs): - if self.id and self.info: - self.path = self.normalize_path() + 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