Skip to content

Report how full the attachment cache is - #164

Open
Bilb wants to merge 1 commit into
session-foundation:clientfrom
Bilb:feat/attachment-cache-size
Open

Bilb wants to merge 1 commit into
session-foundation:clientfrom
Bilb:feat/attachment-cache-size

Conversation

@Bilb

@Bilb Bilb commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

There is a getter for the attachment cache's limit and none for its current usage, so a client can show the ceiling but not how close it is. "2.1 GB of 5 GB" needs both halves.

attachment_cache_size() is added in the same two forms as attachment_cache_limit, returning bytes.

It sums the attachment_cache index, so it is bytes on disk: the same measure the limit is in, and the same total eviction compares against — which is what makes the two worth showing side by side. Display pictures are excluded, exactly as they are from the limit. Reading the index rather than walking the directory costs a query, and is exact only for as long as the index is: a file deleted from under us still counts until the sweep set_cache_dir starts finds it gone.

Tests: a new case in tests/test_client/attachments.cpp — 0 before anything is cached, then the sum of the cached files' sizes on disk after each of two arrivals.

Built and run against the client suite: 135 cases, 1012 assertions, passing.

Independent of the two PRs alongside it and mergeable in any order.

Note: tests/static-bundle-test fails to link on client already, before this change (undefined reference to SQLite::Database::exec). Unrelated and untouched.

There was a getter for the cache limit and none for what is in it, so a
client could show the ceiling but not how close to it the cache was.
Summed from the cache index, in bytes on disk, which is the measure the
limit is in and the one eviction compares against.
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.

1 participant