From 61780cb8ba63fec383995a4d3c83fcf4f19d52ce Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Tue, 11 Mar 2025 21:00:40 +0100 Subject: [PATCH 1/2] Add: remove tmp video thumb file after import & update tmp work path --- backend/apps/files/tasks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/apps/files/tasks.py b/backend/apps/files/tasks.py index a3faa28..5ed8434 100644 --- a/backend/apps/files/tasks.py +++ b/backend/apps/files/tasks.py @@ -85,7 +85,7 @@ def generate_video_thumbnail( video_path = pstfile.file.path # 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) thumbnail_filename = f"thumbnail_{pstfile.hash_blake3}.png" @@ -127,6 +127,8 @@ def generate_video_thumbnail( pstfile.save() + os.remove(thumbnail_file_path) + return f"Thumbnail generated and saved to {thumbnail_file_path}" except subprocess.CalledProcessError as e: From 98dd8ade8b676bd3ab85fb52ddb6b93beead9f18 Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Tue, 11 Mar 2025 21:01:40 +0100 Subject: [PATCH 2/2] Remove: redundant file hash check for video thumb --- backend/apps/files/tasks.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/apps/files/tasks.py b/backend/apps/files/tasks.py index 5ed8434..f1651f1 100644 --- a/backend/apps/files/tasks.py +++ b/backend/apps/files/tasks.py @@ -114,8 +114,6 @@ def generate_video_thumbnail( 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 with open(thumbnail_file_path, "rb") as file: