Banners: download those in the server's files, larger and slower ones

Not every banner arrived:

- Banners kept in the server's own files are linked as ts3image://
  (TeamSpeak 5 and 6: ts3image://<host>?port=…&channel=…&path=…&filename=…,
  the file browser's ts3file:// link with its scheme changed; TeamSpeak 3:
  ts3image://<name>?channel=…&path=…). Only http(s) was fetched, so these
  never were. They now come through the voice connection's file transfer
  (files::server_image), cached under the server and the address.
- A web download had 16 MiB at most and 30 seconds in all, while up to
  eight run at once: a large animated banner, or several on a slow link,
  failed and failed again on every retry. Pictures may now be 64 MiB and
  go to disk as they arrive instead of into memory; a download fails when
  nothing arrives for 20 s or when, after its first 30 s, it averages less
  than 32 KiB/s. Accept names the formats the UI decodes.
- Pictures over file transfer had 30 seconds too; now 30 s plus their
  size at 32 KiB/s, and at most 64 MiB.

The voice protocol's MAX_DECOMPRESSED_SIZE goes back to 2 MiB: it bounds
compressed commands (the channel list), not pictures, and QuickLZ reserves
the size a packet declares, so 1 GiB let any server make the client
allocate a gigabyte with one small packet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEpqsPES27Eacue91u3d2Q
This commit is contained in:
Claude committed 2026-10-04 16:37:02 +00:00
1 parent 3f177a77aa
commit 86c30b6f8f
8 files changed
+333 -58

No files matched your search

+16
View File
@@ -77,6 +77,16 @@ pub(crate) fn icon_key(id: u32) -> String {
format!("icons/{id}")
}
/// The largest picture downloaded into the cache, from the web or from the
/// server's files: animated banners of several megabytes are common. The
/// download goes to disk as it arrives, so this bounds the disk, not memory.
pub(crate) const MAX_PICTURE_BYTES: u64 = 64 << 20;
/// The slowest a picture may arrive on average after its first seconds:
/// a large banner on a slow link still arrives, one trickling in forever
/// does not hold a download slot.
pub(crate) const MIN_PICTURE_RATE: u64 = 32 << 10;
/// The cache key of a picture on the web: only `http` and `https`
/// addresses.
pub(crate) fn picture_key(url: &str) -> Option<String> {
@@ -85,6 +95,12 @@ pub(crate) fn picture_key(url: &str) -> Option<String> {
(web && !rest.is_empty()).then(|| format!("pictures/{:x}", md5::compute(url)))
}
/// The cache key of a picture in a server's files (`ts3image://`): the
/// same address names another file on another server.
pub(crate) fn server_picture_key(server: &str, url: &str) -> String {
format!("pictures/{:x}", md5::compute(format!("{server}\n{url}")))
}
impl Cache {
/// A cache in `dir` (created when the first file arrives).
pub fn new(dir: impl Into<PathBuf>) -> Self {