From 9596248dc4733dabe6a54e22fcec67bd343c2019 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 31 Jul 2019 11:53:30 +0200 Subject: [PATCH] use refresh_from_db --- pandora/archive/models.py | 5 ++--- pandora/archive/tasks.py | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 306590b20..3b437fedf 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -756,9 +756,8 @@ class Stream(models.Model): ok, error = extract.stream(media, target, self.name(), info, flags=self.flags) # file could have been moved while encoding # get current version from db and update - _self = Stream.objects.get(id=self.id) - _self.update_status(ok, error) - return _self + self.refresh_from_db() + self.update_status(ok, error) def get_index(self): index = 1 diff --git a/pandora/archive/tasks.py b/pandora/archive/tasks.py index 2443149af..92446d585 100644 --- a/pandora/archive/tasks.py +++ b/pandora/archive/tasks.py @@ -128,7 +128,7 @@ def process_stream(fileId): stream = streams[0] stream.make_timeline() stream.extract_derivatives() - file = models.File.objects.get(id=fileId) + file.refresh_from_db() file.encoding = False file.save() file.item.update_selected() @@ -158,13 +158,12 @@ def extract_stream(fileId): if created: file.extract_frames() stream.media.name = stream.path(stream.name()) - stream = stream.encode() + stream.encode() if stream.available: stream.make_timeline() stream.extract_derivatives() file.extract_tracks() - # get current version from db - file = models.File.objects.get(id=fileId) + file.refresh_from_db() if not file.item.rendered \ and not file.item.files.exclude(id=fileId).filter(Q(queued=True) | Q(encoding=True)).count(): file.item.update_timeline()