Both call directory_scanner_create() with the same 9 arguments: root_directory, use_metadata, chunk_size, exclude_patterns, exclude_count, include_patterns, include_count, max_size, min_size.
3. Connection setup is duplicated (3 connection paths, same pattern)
The TCP / TLS / SSH connection logic appears in both send_files() (lines 383–410) and send_chunks_multithreaded() (lines 225–252) — the code is structurally identical.
4. Manifest sending is duplicated
The code to serialize and send ArrayList* manifest via STATUS_MANIFEST appears in both send_files() (lines 462–478) and send_chunks_multithreaded() (lines 264–273).
Location
src/client/client_send.c:361-380, :416-419, :462-478, :500-520 and src/client/client_send.c:225-252, :264-273, :300-304
Suggested Fix
Extract dry-run into a helper: static int dry_run(Config* config).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Description
The two main transfer entry points in
src/client/client_send.ccontain significant duplicated code:1. Dry-run logic is duplicated (51 identical lines)
send_files()lines 361–380send_files_multithreaded()lines 501–520Both functions create a scanner, iterate chunks, count files/bytes, print output, and return — with identical logic.
2. Scanner creation is duplicated (9 identical arguments)
send_files()lines 416–419send_files_multithreaded()(insidescan_directory_multithreaded) lines 300–304Both call
directory_scanner_create()with the same 9 arguments: root_directory, use_metadata, chunk_size, exclude_patterns, exclude_count, include_patterns, include_count, max_size, min_size.3. Connection setup is duplicated (3 connection paths, same pattern)
The TCP / TLS / SSH connection logic appears in both
send_files()(lines 383–410) andsend_chunks_multithreaded()(lines 225–252) — the code is structurally identical.4. Manifest sending is duplicated
The code to serialize and send
ArrayList* manifestviaSTATUS_MANIFESTappears in bothsend_files()(lines 462–478) andsend_chunks_multithreaded()(lines 264–273).Location
src/client/client_send.c:361-380,:416-419,:462-478,:500-520andsrc/client/client_send.c:225-252,:264-273,:300-304Suggested Fix
static int dry_run(Config* config).static Client* connect_client(Config* config).static bool send_manifest(int fd, ArrayList* manifest).Severity
Medium
Category
Quality / Maintainability