forked from 0x2620/pandora
make sure path is normalized on first save
This commit is contained in:
parent
8d96cd80ce
commit
ad89e9ffed
1 changed files with 9 additions and 2 deletions
|
@ -226,8 +226,12 @@ class File(models.Model):
|
||||||
self.parse_info()
|
self.parse_info()
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.id and self.info:
|
update_path = False
|
||||||
self.path = self.normalize_path()
|
if self.info:
|
||||||
|
if self.id:
|
||||||
|
self.path = self.normalize_path()
|
||||||
|
else:
|
||||||
|
update_path = True
|
||||||
if self.item:
|
if self.item:
|
||||||
data = self.get_path_info()
|
data = self.get_path_info()
|
||||||
self.extension = data.get('extension')
|
self.extension = data.get('extension')
|
||||||
|
@ -257,6 +261,9 @@ class File(models.Model):
|
||||||
self.available = not self.uploading and \
|
self.available = not self.uploading and \
|
||||||
self.streams.filter(source=None, available=True).count() > 0
|
self.streams.filter(source=None, available=True).count() > 0
|
||||||
super(File, self).save(*args, **kwargs)
|
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):
|
def get_path(self, name):
|
||||||
h = self.oshash
|
h = self.oshash
|
||||||
|
|
Loading…
Reference in a new issue