use refresh_from_db

This commit is contained in:
j 2019-07-31 11:53:30 +02:00
parent 794b28f833
commit 9596248dc4
2 changed files with 5 additions and 7 deletions

View file

@ -756,9 +756,8 @@ class Stream(models.Model):
ok, error = extract.stream(media, target, self.name(), info, flags=self.flags) ok, error = extract.stream(media, target, self.name(), info, flags=self.flags)
# file could have been moved while encoding # file could have been moved while encoding
# get current version from db and update # get current version from db and update
_self = Stream.objects.get(id=self.id) self.refresh_from_db()
_self.update_status(ok, error) self.update_status(ok, error)
return _self
def get_index(self): def get_index(self):
index = 1 index = 1

View file

@ -128,7 +128,7 @@ def process_stream(fileId):
stream = streams[0] stream = streams[0]
stream.make_timeline() stream.make_timeline()
stream.extract_derivatives() stream.extract_derivatives()
file = models.File.objects.get(id=fileId) file.refresh_from_db()
file.encoding = False file.encoding = False
file.save() file.save()
file.item.update_selected() file.item.update_selected()
@ -158,13 +158,12 @@ def extract_stream(fileId):
if created: if created:
file.extract_frames() file.extract_frames()
stream.media.name = stream.path(stream.name()) stream.media.name = stream.path(stream.name())
stream = stream.encode() stream.encode()
if stream.available: if stream.available:
stream.make_timeline() stream.make_timeline()
stream.extract_derivatives() stream.extract_derivatives()
file.extract_tracks() file.extract_tracks()
# get current version from db file.refresh_from_db()
file = models.File.objects.get(id=fileId)
if not file.item.rendered \ if not file.item.rendered \
and not file.item.files.exclude(id=fileId).filter(Q(queued=True) | Q(encoding=True)).count(): and not file.item.files.exclude(id=fileId).filter(Q(queued=True) | Q(encoding=True)).count():
file.item.update_timeline() file.item.update_timeline()