From 020a3e1808d0d1371f176665bea9a6c06d45349f Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 3 Jul 2011 20:11:35 +0200 Subject: [PATCH] cache stream state --- pandora/archive/views.py | 2 +- pandora/item/models.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 1e992b067..429cd2167 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -227,7 +227,7 @@ def moveFiles(request): ''' change file / item link param data { - ids: hashes of files + ids: ids of files itemId: new itemId } diff --git a/pandora/item/models.py b/pandora/item/models.py index 5dce528b1..3ef6366da 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -123,6 +123,7 @@ class Item(models.Model): torrent = models.FileField(default=None, blank=True, upload_to=lambda i, x: i.path('torrent.torrent')) + stream_info = fields.DictField(default={}, editable=False) #stream related fields stream_aspect = models.FloatField(default=4/3) @@ -671,15 +672,14 @@ class Item(models.Model): self.torrent.name = self.path('torrent/%s.torrent' % self.get('title')) self.save() - def update_streams(self): + def update_streams(self, force=False): files = {} for f in self.main_videos(): files[utils.sort_title(f.name)] = f.video.path - - #FIXME: how to detect if something changed? - if files: + if force or self.stream_info != files: + self.stream_info = files stream, created = Stream.objects.get_or_create(item=self, - profile=settings.VIDEO_PROFILE) + profile=settings.VIDEO_PROFILE) stream.video.name = stream.path() cmd = [] if os.path.exists(stream.video.path):