Fix: check if file is imported before saving to db
This commit is contained in:
parent
0e6146c6e8
commit
7fd888aae2
1 changed files with 6 additions and 4 deletions
|
@ -112,15 +112,17 @@ def generate_video_thumbnail(
|
|||
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
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:
|
||||
pstfile.thumbnail.save(thumbnail_filename, file)
|
||||
|
||||
pstfile.thumbnail_hash_blake3 = compute_file_hash_blake3(
|
||||
thumbnail_file_path
|
||||
)
|
||||
pstfile.thumbnail_hash_blake3 = thumbnail_hash_blake3
|
||||
|
||||
print(compute_blur_hash(thumbnail_file_path))
|
||||
pstfile.thumbnail_blur_hash = compute_blur_hash(thumbnail_file_path)
|
||||
|
||||
pstfile.save()
|
||||
|
|
Loading…
Add table
Reference in a new issue