use info of all files in same volume to normalize path

This commit is contained in:
j 2013-05-31 12:14:23 +00:00
parent 1502a5992e
commit 9dafefdcf2

View file

@ -166,13 +166,31 @@ class File(models.Model):
def normalize_path(self): def normalize_path(self):
#FIXME: always use format_path #FIXME: always use format_path
if settings.CONFIG['site']['folderdepth'] == 4: if settings.CONFIG['site']['folderdepth'] == 4:
return ox.movie.format_path(self.get_path_info()) return self.normalize_item_path()
else: else:
path = self.path or '' path = self.path or ''
if self.instances.all().count(): if self.instances.all().count():
path = self.instances.all()[0].path path = self.instances.all()[0].path
return path return path
def normalize_item_path(self):
files = []
instance = self.instances.all()[0]
for f in self.item.files.filter(instances__volume=instance.volume):
files.append(f.get_path_info())
files[-1].update({
'path': instance.path,
'time': instance.mtime,
'oshash': f.oshash,
'size': f.size
})
info = ox.movie.parse_item_files(files)
for version in info:
p = filter(lambda f: f['oshash'] == self.oshash, version['files'])
if p:
return p[0]['path']
def update_info(self, info, user): def update_info(self, info, user):
#populate name sort with director if unknown #populate name sort with director if unknown
if info.get('director') and info.get('directorSort'): if info.get('director') and info.get('directorSort'):