Skip to content

feat: symlink media/thumbs/key/<prefix>/<key> to thumbnail files - #1625

Merged
tcely merged 2 commits into
meeb:test-contributionsfrom
MbappeWU:feat/thumbs-key-symlink
Oct 28, 2026
Merged

tcely merged 2 commits into
meeb:test-contributionsfrom
MbappeWU:feat/thumbs-key-symlink

Conversation

@MbappeWU

Copy link
Copy Markdown

Closes #1621.

Problem

Thumbnail files live under MEDIA_ROOT/thumbs/<uuid[:2]>/<uuid>.jpg, so listing which thumbs are still referenced by the database requires querying SQLite. A key-indexed symlink tree makes active thumbs a filesystem set difference.

Approach

  • Add sync/thumb_key.py helpers that maintain MEDIA_ROOT/thumbs/key/<key[:2]>/<key> as a relative symlink to the uuid jpeg.
  • Call sync_media_thumb_key_symlink from media_post_save.
  • Use a custom ImageFieldFile subclass so thumb.delete(save=False) still removes the key link.
  • Reject empty / path-like keys; leave a non-symlink collision alone.

No backfill command in this PR (new saves and deletes stay consistent; existing rows can be refreshed by re-saving thumbs later if wanted).

Verification

TUBESYNC_DEBUG=True python manage.py test sync.tests.test_thumb_key_symlink -v2
# 6 tests OK

Tip: 43fbb49

MbappeWU and others added 2 commits October 27, 2026 18:33
Saving a thumbnail should leave thumbs/key/<prefix>/<key> pointed at the uuid jpeg so active files can be listed without the database.

Co-authored-by: Cursor <cursoragent@cursor.com>
post_save keeps the link aligned after every media save. Deleting the thumbnail file removes that link even when the model is not saved.

Co-authored-by: Cursor <cursoragent@cursor.com>
@tcely
tcely self-requested a review October 28, 2026 09:00
@tcely tcely added enhancement New feature or request help wanted Extra attention is needed labels Oct 28, 2026
@tcely tcely moved this to In Progress in Status Oct 28, 2026
@tcely
tcely changed the base branch from main to test-contributions October 28, 2026 09:20

@tcely tcely left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! This all looks good to me.

@github-project-automation github-project-automation Bot moved this from In Progress to Ready in Status Oct 28, 2026
@tcely
tcely merged commit 6671496 into meeb:test-contributions Oct 28, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in Status Oct 28, 2026
tcely added a commit that referenced this pull request Oct 28, 2026
 feat: symlink media/thumbs/key/<prefix>/<key> to thumbnail files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request help wanted Extra attention is needed

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Link media/thumbs/key/KE/KEY to the actual file

2 participants