Skip to content

Comments

feat(backup): add option to skip media download for some chats#74

Merged
GeiserX merged 3 commits intoGeiserX:masterfrom
Farzadd:feat/skip-media-download
Feb 16, 2026
Merged

feat(backup): add option to skip media download for some chats#74
GeiserX merged 3 commits intoGeiserX:masterfrom
Farzadd:feat/skip-media-download

Conversation

@Farzadd
Copy link
Contributor

@Farzadd Farzadd commented Feb 16, 2026

Summary

For users with certain chats or groups that generate a lot of media, this option adds the ability to skip media download for those chats only

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that causes existing functionality to change)
  • Documentation update
  • Infrastructure/CI change

Database Changes

  • Schema changes (Alembic migration required)
  • Data migration script added in scripts/
  • No database changes

Data Consistency Checklist

  • All chat_id values use marked format (via _get_marked_id())
  • All datetime values pass through _strip_tz() before DB operations
  • INSERT and UPDATE operations handle the same fields identically

Testing

  • Tests pass locally (python -m pytest tests/ -v)
  • Linting passes (ruff check .)
  • Formatting passes (ruff format --check .)
  • Manually tested in development environment

Security Checklist

  • No secrets or credentials committed
  • User input properly validated/sanitized
  • Authentication/authorization properly checked

Deployment Notes

  • Includes an update to the precommit hooks configuration as previous config did not support py314 as the target version for ruff

@Farzadd Farzadd requested a review from GeiserX as a code owner February 16, 2026 09:50
@GeiserX
Copy link
Owner

GeiserX commented Feb 16, 2026

Thanks for the PR! The skip logic looks solid, but there's a missing piece:

When SKIP_MEDIA_CHAT_IDS is enabled for a chat that already has downloaded media, the existing media files on disk (and their database records) are left untouched. This means you end up in an inconsistent state — old media is kept but new media is never downloaded.

Requested change: When a chat is in SKIP_MEDIA_CHAT_IDS, the backup process should also delete existing media files from disk and remove the corresponding media records from the database for those chats. This way, enabling the skip actually reclaims the storage those files were using, which is likely the whole reason someone would want to skip media for a chat in the first place.

This could run once at startup or at the beginning of each backup cycle — detect chats in the skip list that still have media records, delete the files, and clean up the DB rows.

@Farzadd
Copy link
Contributor Author

Farzadd commented Feb 16, 2026

Thanks for the PR! The skip logic looks solid, but there's a missing piece:

When SKIP_MEDIA_CHAT_IDS is enabled for a chat that already has downloaded media, the existing media files on disk (and their database records) are left untouched. This means you end up in an inconsistent state — old media is kept but new media is never downloaded.

Requested change: When a chat is in SKIP_MEDIA_CHAT_IDS, the backup process should also delete existing media files from disk and remove the corresponding media records from the database for those chats. This way, enabling the skip actually reclaims the storage those files were using, which is likely the whole reason someone would want to skip media for a chat in the first place.

This could run once at startup or at the beginning of each backup cycle — detect chats in the skip list that still have media records, delete the files, and clean up the DB rows.

Thanks for the review! That's a great idea, any objections to making that an additional configuration (defaulting to TRUE)?

Otherwise, I'll update the PR with that added.

@Farzadd Farzadd changed the title Feat/skip media download feat(backup): add option to skip media download for some chats Feb 16, 2026
@GeiserX GeiserX merged commit 61eb848 into GeiserX:master Feb 16, 2026
7 checks passed
@GeiserX
Copy link
Owner

GeiserX commented Feb 16, 2026

Merged! Thanks for the contribution @Farzadd, great feature and clean implementation. I'll push a follow-up commit to handle an edge case with media deduplication and then cut a v6.3.0 release including this.

GeiserX added a commit that referenced this pull request Feb 16, 2026
- Symlink removal no longer inflates freed-bytes count (only real
  file deletions count toward reclaimed storage)
- Empty chat media directories are removed after cleanup
- Session-level cache prevents redundant DB queries on subsequent
  backup cycles
- Add 9 unit tests covering real files, symlinks, mixed scenarios,
  empty dirs, missing files, DB errors, and session cache

Follows up on #74 (SKIP_MEDIA_CHAT_IDS feature)
@Farzadd Farzadd deleted the feat/skip-media-download branch February 16, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants