Fix: Finish a directory-only download instead of waiting for the timeout

The completion check compared filesDone against totalFiles minus
directoryCount and only ran on COMMAND_FILE_COMPLETE_V2. The client
sends no COMPLETE for directory entries, so a download of an empty
directory, or of a tree that holds only subdirectories, had zero
expected files and could never satisfy the check. The call sat there
until timeout_ms expired (600 s by default) and then reported 1002.

Mark the session done as soon as the directory entries account for
every entry the client declared. Verified with the debug client: an
empty directory returns in 0.2 s with zero files, a tree of nested
subdirectories returns in 0.2 s with the directories created, and a
directory holding three files still downloads them with the same
sizes and hashes as before.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-10-25 14:16:46 +01:00
1 parent 8f718d9b39
commit 39f0928de7
2 files changed
+13

No files matched your search

+7
View File
@@ -7068,6 +7068,13 @@ void CMcpServer::OnFileChunkV2(uint64_t device_id, context* streamSubCtx, const
}
s.directoryCount++;
RecvFileChunkV2((char*)buf, len, nullptr, nullptr, hash, hmac, 0);
// 纯目录树(空目录、只有子目录):期望文件数 = totalFiles - directoryCount = 0,
// 而客户端对目录项不发 COMPLETE 包,完成判定永远等不到 → 只能干等到超时。
// 目录项数已覆盖全部条目时直接判完成(totalFiles 含目录项,见 F4)。
if (s.totalFiles > 0 && s.directoryCount >= s.totalFiles) {
s.done = true;
m_FileXferCv.notify_one();
}
return;
}