From 9dafefdcf2922097caad6789274b5f34aa05ef1e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 31 May 2013 12:14:23 +0000 Subject: [PATCH] use info of all files in same volume to normalize path --- pandora/archive/models.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 538982d62..353626df4 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -166,13 +166,31 @@ class File(models.Model): def normalize_path(self): #FIXME: always use format_path if settings.CONFIG['site']['folderdepth'] == 4: - return ox.movie.format_path(self.get_path_info()) + return self.normalize_item_path() else: path = self.path or '' if self.instances.all().count(): path = self.instances.all()[0].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): #populate name sort with director if unknown if info.get('director') and info.get('directorSort'):