Skip to content

Background media download in the daemon, with a disk quota #99

Open

Description

@neoromantic

tg media download (#22) fetches one attachment when asked, and the daemon downloads nothing. To keep the files of chosen chats on disk without asking each time, the daemon has to download in the background.

Proposed:

  • Download rules per chat type and media kind, with a size limit (for example photos and voice messages up to 10 MB in DMs). Off by default.
  • A download queue per account: a manual download goes first, a concurrency limit applies, and the queue shares FLOOD_WAITs and connections with sync jobs.
  • A disk quota per account for downloaded media. The least recently used files go first; pinned chats or files stay.
  • tg status shows the queue and the media size against the quota.

Questions:

  • The daemon is read-only: it never sends, edits or deletes. Downloading only reads from Telegram, but Send and download media #22 said the daemon downloads nothing, so this changes a documented rule.
  • How the queue survives a restart and resumes partial files.
  • Where per-file state (last access, pins) lives, next to the account's cache.

Done when e2e tests with a mocked client show the rules pick the right messages, the quota evicts the least recently used files and keeps pinned ones, and a short live daemon run downloads a new voice message in a test chat.

Activity

  1. added
    enhancement
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions