fix(db): normalize stale positive-ID media file paths#168
Conversation
Before v4.0.5, backup stored media in directories named with raw positive entity IDs. After v4.0.5, directories use Telethon's marked IDs (negative for groups/channels). The v4.0.6 migration fixed chat_id columns but never updated file_path strings, leaving ~37% of media rows with broken paths. Adds Alembic migration 013 that rewrites file_path values so the folder component matches the marked chat_id. Also fixes the runtime fallback to handle both basic groups (X→-X) and channels (X→-100X), and fixes the ACL check to recognize legacy positive folder IDs. Bump to v7.10.14.
|
Warning Review limit reached
Your plan currently allows 2 reviews/hour. Refill in 24 minutes and 33 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (51.51%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #168 +/- ##
==========================================
- Coverage 92.76% 92.55% -0.22%
==========================================
Files 22 22
Lines 6498 6527 +29
==========================================
+ Hits 6028 6041 +13
- Misses 470 486 +16
🚀 New features to boost your workflow:
|
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
Summary
media.file_pathvalues so the folder component uses the correct marked (negative) chat_id instead of the stale positive entity ID from pre-v4.0.5X→-X) and channels/supergroups (X→-100X)_enforce_media_aclto recognize legacy positive folder IDs for multi-user setupsRoot Cause
Before v4.0.5, the backup used
entity.id(always positive) for directory names. After v4.0.5, it usesget_peer_id()(negative for groups/channels). The v4.0.6migrate_to_marked_ids.sqlfixedchat_idcolumns in all tables but never updatedmedia.file_pathstrings. This left 55,402 out of 150,636 media rows (37%) with paths pointing to non-existent positive-ID directories.Migration Details
chat_idvalues in themediatableabs(chat_id)for basic groups,abs(chat_id) - 1000000000000for channels)file_pathusingREPLACE()— only affects rows with the stale patternTest plan
_derive_stale_folder()unit tests pass for basic groups, channels, users, and edge cases