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 <[email protected]>
This commit is contained in:
VallierDevandClaude Opus 5.5 committed 2026-10-17 00:46:58 +08:00
1 parent 90e802b94a
commit d1791ef861
1 file changed
+6 -2
+6 -2
View File
@@ -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); }