Compare commits

...

2 commits

View file

@ -85,7 +85,7 @@ def generate_video_thumbnail(
video_path = pstfile.file.path video_path = pstfile.file.path
# Create output directory if it doesn't exist # Create output directory if it doesn't exist
output_dir = os.path.join("/tmp/thumbgen/", str(file_id)) output_dir = "/tmp/thumbgen/"
os.makedirs(output_dir, exist_ok=True) os.makedirs(output_dir, exist_ok=True)
thumbnail_filename = f"thumbnail_{pstfile.hash_blake3}.png" thumbnail_filename = f"thumbnail_{pstfile.hash_blake3}.png"
@ -114,8 +114,6 @@ def generate_video_thumbnail(
thumbnail_hash_blake3 = compute_file_hash_blake3(thumbnail_file_path) thumbnail_hash_blake3 = compute_file_hash_blake3(thumbnail_file_path)
if pstfile.thumbnail_hash_blake3 == thumbnail_hash_blake3:
return "Thumbnail already exists for this video file."
# Update the PostFileModel's thumbnail field with the new file # Update the PostFileModel's thumbnail field with the new file
with open(thumbnail_file_path, "rb") as file: with open(thumbnail_file_path, "rb") as file:
@ -127,6 +125,8 @@ def generate_video_thumbnail(
pstfile.save() pstfile.save()
os.remove(thumbnail_file_path)
return f"Thumbnail generated and saved to {thumbnail_file_path}" return f"Thumbnail generated and saved to {thumbnail_file_path}"
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e: