From e3d0893a0006c271b8cd6f99cc38c40e4f014586 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 8 Sep 2012 14:41:19 +0200 Subject: [PATCH] reorder code so that item status does not get overwritten --- pandora/item/models.py | 7 ++++--- pandora/item/tasks.py | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index 1075406e..dd626adf 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1055,10 +1055,10 @@ class Item(models.Model): self.make_icon() if settings.CONFIG['video']['download']: self.make_torrent() - tasks.load_subtitles.delay(self.itemId) - get_sequences.delay(self.itemId) self.rendered = streams.count() > 0 self.save() + tasks.load_subtitles.delay(self.itemId) + get_sequences.delay(self.itemId) def delete_poster(self): if self.poster: @@ -1207,7 +1207,7 @@ class Item(models.Model): def load_subtitles(self): if not utils.get_by_id(settings.CONFIG['layers'], 'subtitles'): - return + return False with transaction.commit_on_success(): layer = 'subtitles' Annotation.objects.filter(layer=layer,item=self).delete() @@ -1268,6 +1268,7 @@ class Item(models.Model): offset += f.duration #remove left over clips without annotations Clip.objects.filter(item=self, annotations__id=None).delete() + return True def srt(self, layer): def format_value(value): diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index bc4d6d31..7480f5ef 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -76,10 +76,10 @@ def rebuild_timeline(itemId): @task(queue="encoding") def load_subtitles(itemId): item = models.Item.objects.get(itemId=itemId) - item.load_subtitles() - item.update_find() - item.update_sort() - item.update_facets() + if item.load_subtitles(): + item.update_find() + item.update_sort() + item.update_facets() @task(ignore_results=True, queue='default') def update_sitemap(base_url):