fix(download): emit failure events on early-returns and update UI transition

Address backend early-return paths that were silently exiting without emitting a
terminal event to the UI, and align the UI transition to "Downloading" with the
actual start of the chunk transfer.

- Added `DownloadGameFilesFailed` event emissions to `handlers.rs` in the
  unhandled early-return branches (when resolved file descriptions are empty or
  when no trusted peers are found without a local copy). This prevents the UI
  from getting stuck in a checking state.
- Updated the frontend `'game-download-pre'` listener to keep the status in
  `CheckingPeers` during peer majority size validation, and let the UI switch
  to `Downloading` only upon `'game-download-begin'`.
- Added clarifying comments explaining the safety and semantic roles of both
  listeners.

Test Plan:
- Run all unit tests to ensure no regressions: `just test`
- Compile and build the Tauri project: `just build`
This commit is contained in:
2026-05-19 22:59:36 +02:00
parent 2b3851f837
commit b7df2de6a5
2 changed files with 13 additions and 1 deletions
+8
View File
@@ -251,6 +251,9 @@ pub async fn handle_download_game_files_command(
log::error!(
"No validated file descriptions available to download game {id}; request metadata first"
);
if let Err(send_err) = tx_notify_ui.send(PeerEvent::DownloadGameFilesFailed { id }) {
log::error!("Failed to send DownloadGameFilesFailed event: {send_err}");
}
return;
}
@@ -277,6 +280,11 @@ pub async fn handle_download_game_files_command(
}
} else {
log::error!("No trusted peers available after majority validation for game {id}");
if let Err(send_err) =
tx_notify_ui.send(PeerEvent::DownloadGameFilesFailed { id: id.clone() })
{
log::error!("Failed to send DownloadGameFilesFailed event: {send_err}");
}
}
return;
}