This commit is contained in:
Markos Gogoulos 2025-05-15 23:38:48 +03:00
parent ce2d744aca
commit b06050e2df
2 changed files with 6 additions and 7 deletions

View File

@ -639,9 +639,8 @@ class Media(models.Model):
self.preview_file_path = "" self.preview_file_path = ""
else: else:
self.preview_file_path = encoding.media_file.path self.preview_file_path = encoding.media_file.path
self.save(update_fields=["listable", "preview_file_path"])
self.save(update_fields=["encoding_status", "listable"]) self.save(update_fields=["encoding_status", "listable", "listable", "preview_file_path"])
if encoding and encoding.status == "success" and encoding.profile.codec == "h264" and action == "add" and not encoding.chunk: if encoding and encoding.status == "success" and encoding.profile.codec == "h264" and action == "add" and not encoding.chunk:
from . import tasks from . import tasks
@ -1237,7 +1236,9 @@ class Encoding(models.Model):
if isinstance(progress, int): if isinstance(progress, int):
if 0 <= progress <= 100: if 0 <= progress <= 100:
self.progress = progress self.progress = progress
self.save(update_fields=["progress"]) # save object with filter update
# to avoid calling signals
Encoding.objects.filter(pk=self.pk).update(progress=progress)
return True return True
return False return False

View File

@ -466,10 +466,8 @@ def create_hls(friendly_token):
pp = os.path.join(output_dir, "master.m3u8") pp = os.path.join(output_dir, "master.m3u8")
if os.path.exists(pp): if os.path.exists(pp):
if media.hls_file != pp: if media.hls_file != pp:
media.hls_file = pp Media.objects.filter(pk=media.pk).update(hls_file=pp)
media.save(update_fields=["hls_file"]) hlsfile = Media.objects.filter(pk=media.pk).first().hls_file
hlsfile = Media.objects.filter(friendly_token=friendly_token).first().hls_file
# print file and size
logger.info(f"HLS file created: {hlsfile} size {os.path.getsize(hlsfile)}") logger.info(f"HLS file created: {hlsfile} size {os.path.getsize(hlsfile)}")
return True return True