Feature: Make Linux a copy_files_c2c destination
The C2C file transfer tool required both ends to be Windows clients. A Linux client can already land the files: the Windows source worker builds every entry name by plain string concatenation of dst_dir and the relative path, so a POSIX dst_dir such as /tmp/recv arrives as "/tmp/recv\sub\file", which the POSIX receiver normalizes to "/" and writes below an absolute path. What was missing was the server gate and any way to tell whether the writes succeeded. The server now accepts LNX/MAC destinations instead of rejecting them, and validates dst_dir by destination type: an absolute Windows path for Windows targets, an absolute POSIX path without backslashes for POSIX targets. The paths and dst_dir arguments also reject embedded NULs, and a POSIX dst_dir is converted to CP936 exactly so unencodable characters fail loudly instead of silently becoming '?'. To make receiver_ack meaningful, a Linux client that receives a C2C transfer now reports what it wrote. It tracks the outcome per transferID, counting a directory entry, the last chunk of a file and the completion packet of an empty file as the three ways an item is settled, with done sets so that source retries and the trailing completion packet never double count. When every item is settled it sends one C2CSendResultPacket back on its main connection under the new TOKEN_C2C_RECV_RESULT (176), with the first errno in the win32err field and the mapped FEV2_* status. A dedicated token is used instead of reusing 175 because a host can be the destination of one transfer while being the source of another, and a destination result must never latch the source side's done flag. The server waits up to five seconds for that acknowledgement after the source reports success, and only for destinations advertising the new CLIENT_CAP_C2C_RECV_ACK capability bit (Linux only, macOS reports nothing). A failed acknowledgement becomes -32011 with the status, errno and received file count; a missing acknowledgement stays an error only for transfers that actually moved bytes, since a transfer of empty files alone gives the receiver nothing to learn totalFiles from. Windows destinations are unchanged and skip the wait entirely. Verified on the debug instance: Windows to Linux (WSL Ubuntu 24.04) with subdirectories, an empty directory, a Chinese file name and a 3 MB binary lands with matching SHA-256 and receiver_ack true; a Windows-style dst_dir returns -32602; an unwritable POSIX destination returns -32011; the existing Windows to Windows cases still pass with receiver_ack false and the same latency. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
4c0e86dcc5
commit
4146c73657
11 files changed
+384
-48
No files matched your search
+2
-2
@@ -455,8 +455,8 @@ int DataProcess(void* user, PBYTE szBuffer, ULONG ulLength)
|
||||
FileTransferV2::HandleC2CPrepare(szBuffer, ulLength, nullptr);
|
||||
Mprintf("** [%p] C2C Prepare received ***\n", user);
|
||||
} else if (szBuffer[0] == COMMAND_SEND_FILE_V2 || szBuffer[0] == COMMAND_FILE_COMPLETE_V2) {
|
||||
// V2 文件接收
|
||||
int result = FileTransferV2::RecvFileChunkV2(szBuffer, ulLength, g_myClientID);
|
||||
// V2 文件接收;g_pMainClient 用于 C2C 落盘回执(DataProcess 的 user 恒为 NULL)
|
||||
int result = FileTransferV2::RecvFileChunkV2(szBuffer, ulLength, g_myClientID, g_pMainClient);
|
||||
if (result != 0) {
|
||||
Mprintf("** [%p] V2 File recv error: %d ***\n", user, result);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user