Skip to content
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

Thumbnail server: Some fixes #3087

Merged
merged 6 commits into from
Nov 23, 2019
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Look up ID earlier, error if not found
  • Loading branch information
ferdnyc committed Nov 20, 2019
commit 9fb11f87596313d5a0bbbf397574b2d9eeba2e5f
18 changes: 10 additions & 8 deletions src/classes/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,14 @@ def do_GET(self):
file_frame = int(url_output.group('file_frame'))
only_path = url_output.group('only_path')

# Catch undefined calls
if file_id == "undefined":
try:
# Look up file data
file = File.get(id=file_id)

# Ensure file location is an absolute path
file_path = file.absolute_path()
except AttributeError:
# Couldn't match file ID
self.send_error(404)
return

Expand All @@ -137,18 +143,14 @@ def do_GET(self):
# Locate thumbnail
thumb_path = os.path.join(info.THUMBNAIL_PATH, file_id, "%s.png" % file_frame)
if not os.path.exists(thumb_path) and file_frame == 1:
# Try with no frame # (for backwards compatibility)
# Try ID with no frame # (for backwards compatibility)
thumb_path = os.path.join(info.THUMBNAIL_PATH, "%s.png" % file_id)
if not os.path.exists(thumb_path) and file_frame != 1:
# Try with no frame # (for backwards compatibility)
# Try with ID and frame # in filename (for backwards compatibility)
thumb_path = os.path.join(info.THUMBNAIL_PATH, "%s-%s.png" % (file_id, file_frame))

if not os.path.exists(thumb_path):
# Generate thumbnail (since we can't find it)
file = File.get(id=file_id)

# Convert path to the correct relative path (based on this folder)
file_path = file.absolute_path()

# Determine if video overlay should be applied to thumbnail
overlay_path = ""
Expand Down