Quality: Refactor long sender functions and duplicated dry-run logic #196

Closed
opened 2026-07-30 18:35:07 +02:00 by TapTap · 0 comments
Owner

Severity: low
Category: quality
Location: src/client/client_send.c:307-427, src/client/client_send.c:429-485

Description:
send_files() and send_files_multithreaded() are both ~150+ lines and mix multiple responsibilities: argument handling, connection setup, directory scanning, manifest tracking, progress reporting, and cleanup. In addition, the dry-run logic is duplicated almost verbatim in both functions (src/client/client_send.c:307-328 and src/client/client_send.c:429-449).

Suggested fix:

  1. Extract a shared dry_run_scan() helper that takes a Config* and prints the dry-run report.
  2. Split send_files() into smaller functions:
    • connect_client(config)
    • send_files_loop(client, config, scanner, manifest)
    • send_manifest_and_finish(client, manifest)
  3. Split send_files_multithreaded() similarly and reuse the connection/finish helpers.
  4. Keep each function under 80 lines and with a single responsibility.

Labels: quality, refactoring

**Severity:** low **Category:** quality **Location:** `src/client/client_send.c:307-427`, `src/client/client_send.c:429-485` **Description:** `send_files()` and `send_files_multithreaded()` are both ~150+ lines and mix multiple responsibilities: argument handling, connection setup, directory scanning, manifest tracking, progress reporting, and cleanup. In addition, the dry-run logic is duplicated almost verbatim in both functions (`src/client/client_send.c:307-328` and `src/client/client_send.c:429-449`). **Suggested fix:** 1. Extract a shared `dry_run_scan()` helper that takes a `Config*` and prints the dry-run report. 2. Split `send_files()` into smaller functions: - `connect_client(config)` - `send_files_loop(client, config, scanner, manifest)` - `send_manifest_and_finish(client, manifest)` 3. Split `send_files_multithreaded()` similarly and reuse the connection/finish helpers. 4. Keep each function under 80 lines and with a single responsibility. **Labels:** quality, refactoring
TapTap added the qualityneeds-triage labels 2026-07-30 18:35:07 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#196