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:
@@ -132,11 +132,15 @@ export const useGames = (rescanGameDir: () => void): UseGamesResult => {
|
||||
});
|
||||
}));
|
||||
|
||||
// 'game-download-pre' confirms peer metadata was found. The backend may still
|
||||
// reject the download during majority validation (which now emits a terminal fail event),
|
||||
// so keep showing CheckingPeers until 'game-download-begin' reports that transfer started.
|
||||
unlisteners.push(await listen('game-download-pre', (e) => {
|
||||
const id = e.payload as string;
|
||||
updateById(id, { install_status: InstallStatus.Downloading, clearStatus: true });
|
||||
updateById(id, { install_status: InstallStatus.CheckingPeers, clearStatus: true });
|
||||
}));
|
||||
|
||||
// 'game-download-begin' signals consensus size validation has completed and file transfer has started.
|
||||
unlisteners.push(await listen('game-download-begin', (e) => {
|
||||
const id = e.payload as string;
|
||||
updateById(id, { install_status: InstallStatus.Downloading, clearStatus: true });
|
||||
|
||||
Reference in New Issue
Block a user