From d1791ef861f09336950099e800c9bc5ced761de0 Mon Sep 17 00:00:00 2001 From: VallierDev <24893073+VallierDev@users.noreply.github.com> Date: Sat, 17 Oct 2026 00:46:58 +0800 Subject: [PATCH] File transfer: omit the inline listing copy when the reply would not fit Large folders (5600 entries) were sent both inline and as zlib dir_data in one message, beyond the 256 KB SCTP limit, so the reply was dropped and the viewer spun until its timeout. dir_data (what current viewers read) is always sent. Co-Authored-By: Claude Opus 5.5 --- src/file_trans.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/file_trans.rs b/src/file_trans.rs index 8a9a587..c759a87 100644 --- a/src/file_trans.rs +++ b/src/file_trans.rs @@ -392,8 +392,12 @@ impl FileSession { let mut listing = Enc::default(); for e in &entries { listing = listing.bytes(1, &e.0); } let compressed = zlib(&listing.0); - log::info!("File transfer read_dir: request_id={} root={} entries={} dir_data_bytes={}", rid, path.is_empty(), entries.len(), compressed.len()); - for e in entries { body = body.msg(3, e); } + // Both copies in one message: a 5600-entry folder is ~73 KB compressed but several hundred KB + // inline, beyond the 256 KB SCTP message limit, and the reply was dropped. Keep the inline copy + // only when the message still fits; current viewers read dir_data. + let inline = listing.0.len() + compressed.len() < 200_000; + log::info!("File transfer read_dir: request_id={} root={} entries={} dir_data_bytes={} inline={}", rid, path.is_empty(), entries.len(), compressed.len(), inline); + if inline { for e in entries { body = body.msg(3, e); } } body = body.uint(4, FT_SUCCEEDED).bytes(5, &compressed); } Err(code) => { log::info!("File transfer read_dir failed: request_id={} error={}", rid, code); body = body.uint(4, code); }