Skip to content

Fix: Gallery Thumbnails Failing to Re-Assign #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions gallery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import zipfile
import re
import requests
import subprocess
import tempfile

Expand Down Expand Up @@ -772,7 +773,12 @@ def display_thumbnail(file_id: int, auth_dict: Optional[Dict[str, Any]] = None):
file_model = File.query.filter(File.id == file_id).first()

link = storage_interface.get_link("thumbnails/{}".format(file_model.s3_id))
return redirect(link)
if "LOCAL_STORAGE_PATH" in app.config:
link = "http://" + app.config["SERVER_NAME"] + link
req = requests.get(link)
if req.status_code == requests.codes.ok:
return req.content
return display_thumbnail(util.DEFAULT_THUMBNAIL_NAME)


@app.route("/api/thumbnail/get/dir/<int:dir_id>")
Expand All @@ -791,7 +797,17 @@ def display_dir_thumbnail(dir_id: int, auth_dict: Optional[Dict[str, Any]] = Non
thumbnail_uuid = thumbnail_uuid.split('.')[0]

link = storage_interface.get_link("thumbnails/{}".format(thumbnail_uuid))
return redirect(link)
if "LOCAL_STORAGE_PATH" in app.config:
link = "http://" + app.config["SERVER_NAME"] + link
req = requests.get(link)
while req.status_code != requests.codes.ok:
dir_model.thumbnail_uuid = refresh_directory_thumbnail(dir_model)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this default to the "no thumbnail" photo if it fails to generate one? Want to be sure this can't loop infinitely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

db.session.commit()
link = storage_interface.get_link("thumbnails/{}".format(thumbnail_uuid))
if "LOCAL_STORAGE_PATH" in app.config:
link = "http://" + app.config["SERVER_NAME"] + link
req = requests.get(link)
return req.content


@app.route("/api/file/next/<int:file_id>")
Expand Down