Skip to content

fix: a stalled transfer gives up; every run's log can be kept whole - #79

Merged
michvllni merged 1 commit into
mainfrom
fix/stalls-and-full-log
Nov 8, 2026
Merged

michvllni merged 1 commit into
mainfrom
fix/stalls-and-full-log

Conversation

@michvllni

Copy link
Copy Markdown
Collaborator

A stalled transfer gives up

A ROM download from a phone's FTP server waited until START. Wi-Fi dropped mid-file, after 118 MB of it had arrived, which sends no error: the connection just goes quiet. libcurl's only limit was the 50 s connect timeout.

  • The timeout: a transfer now gives up after 60 s without receiving a byte (CURLOPT_LOW_SPEED_LIMIT/_TIME in Curl::_applyDefaults(), STALL_SECONDS).
  • What happens next: the result is CURLE_OPERATION_TIMEDOUT, which every provider already retries. If all three attempts fail, the file is listed as failed and the sync goes on.
  • FTP's retry no longer appends to a half-written file. It didn't discard what a stalled download had already written; it now does (rewindDownloadFile(), as WebDAV, Dropbox and Drive already did). It also opens a fresh connection for the retry. Before, this only happened on rare network errors; with the timeout it would be the normal case.

Every run's log can be kept, in full

  • No more trimming: the debug log kept only the first 96 KB and the last 48 KB in memory, so a long run lost exactly the part a report needed.
  • Written as the run goes: every run is now written to /3ds/3DSync/logs/{debug,sync}-<stamp>.log.part on the SD card. Each complete line is stripped of colour codes and passed through debugRedact() before it reaches the card, so the file never holds a token, even mid-run.
  • At the end: the file is renamed to .log when kept, and deleted when not.
  • Advantages: nothing is held in memory, and a crash leaves the log up to that point.
  • Normal runs too: they now get the same question at the end as a debug run (offerLogSave(), frontend::askSaveLog()).

Tests

  • make -C tests: 263 pass. The debuglog suite was rewritten:
    • nothing is captured outside a run;
    • a normal run is captured;
    • every line of a long run is kept;
    • colour codes and secrets never reach the card, including a token split over two writes;
    • a declined log is deleted;
    • a line still open at the end is kept.
  • make -C tests preview renders the prompt after a normal run.
  • The 3DS build has no warnings.

Not yet tested

On a console: the timeout and retry after cutting Wi-Fi mid-file, and the saved logs. A test build with steps exists.

🤖 Generated with Claude Code

- A download from a phone's FTP server waited until START: Wi-Fi dropped
  mid-file, which sends no error, and libcurl had only a connect timeout.
  A transfer now gives up after 60 s without a byte (LOW_SPEED_LIMIT/TIME
  in Curl::_applyDefaults()); every provider already retries a timeout.
- FTP's retry did not discard what a stalled download had written and
  appended the next attempt to the half file; it now rewinds the temp
  file and retries on a fresh connection.
- The debug log kept the first 96 KB and the last 48 KB, so a long run
  lost the part a report needed.  Every run is now written to
  /3ds/3DSync/logs/{debug,sync}-<stamp>.log.part as it goes, each line
  stripped of colour codes and redacted before it reaches the card, and
  renamed to .log when kept or deleted when not.  Nothing is held in
  memory, and a crash leaves the log up to that point.
- Normal runs offer to keep their log too, with the same question as a
  debug run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michvllni
michvllni merged commit d94f37e into main Nov 8, 2026
7 checks passed
@michvllni
michvllni deleted the fix/stalls-and-full-log branch November 8, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant