From 9a3c24b2ab16fafc3b817ba854d28ce652556fcb Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 4 Feb 2015 15:10:51 +0530 Subject: [PATCH] only call update_timeline once during first import, adds empty clips twice otherwise --- pandora/archive/tasks.py | 2 +- pandora/item/models.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pandora/archive/tasks.py b/pandora/archive/tasks.py index 1920c612..3dff1fcb 100644 --- a/pandora/archive/tasks.py +++ b/pandora/archive/tasks.py @@ -107,7 +107,7 @@ def process_stream(fileId): file = models.File.objects.get(id=fileId) file.encoding = False file.save() - file.item.update_selected() + file.item.update_selected(update_timeline=False) if not file.item.rendered: file.item.update_timeline() if file.item.rendered: diff --git a/pandora/item/models.py b/pandora/item/models.py index d602665f..0d2035d2 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1164,7 +1164,7 @@ class Item(models.Model): qs = qs.exclude(id__in=wanted) qs.update(wanted=False) - def update_selected(self): + def update_selected(self, update_timeline=True): sets = self.sets() for s in sets: if s.filter(Q(is_video=True)|Q(is_audio=True)).filter(available=False).count() == 0: @@ -1180,7 +1180,8 @@ class Item(models.Model): if update: self.rendered = False self.save() - tasks.update_timeline.delay(self.public_id) + if update_timeline: + tasks.update_timeline.delay(self.public_id) break if not sets: self.rendered = False @@ -1536,7 +1537,7 @@ class Item(models.Model): return False with transaction.commit_on_success(): layer = subtitles['id'] - Annotation.objects.filter(layer=layer,item=self).delete() + Annotation.objects.filter(layer=layer, item=self).delete() offset = 0 language = '' subtitles = self.files.filter(selected=True, is_subtitle=True, available=True)