mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-10-21 23:01:26 +02:00
fix: first browser download stuck at 0%
This commit is contained in:
1 parent
0789cf0bb9
commit
759263b63f
22 files changed
+291
-49
No files matched your search
@@ -3,6 +3,7 @@ import type { Event as TauriEvent } from "@tauri-apps/api/event";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import i18n from "@/i18n";
|
||||
import { translateBackendError } from "@/lib/backend-errors";
|
||||
import { getBrowserDisplayName } from "@/lib/browser-utils";
|
||||
import { isOnboardingActive } from "@/lib/onboarding-signal";
|
||||
import {
|
||||
@@ -38,6 +39,7 @@ interface DownloadProgress {
|
||||
speed_bytes_per_sec: number;
|
||||
eta_seconds?: number;
|
||||
stage: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
interface BrowserVersionsResult {
|
||||
@@ -418,11 +420,13 @@ export function useBrowserDownload() {
|
||||
),
|
||||
{
|
||||
id: `download-error-${progress.browser}-${progress.version}`,
|
||||
description: i18n.t(
|
||||
wasExtracting
|
||||
? "browserDownload.toast.extractionFailedDescription"
|
||||
: "browserDownload.toast.downloadFailedDescription",
|
||||
),
|
||||
description: progress.error
|
||||
? translateBackendError(i18n.t, progress.error)
|
||||
: i18n.t(
|
||||
wasExtracting
|
||||
? "browserDownload.toast.extractionFailedDescription"
|
||||
: "browserDownload.toast.downloadFailedDescription",
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ interface DownloadProgress {
|
||||
speed_bytes_per_sec: number;
|
||||
eta_seconds?: number | null;
|
||||
stage: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export type SetupPhase = "downloading" | "extracting" | "ready" | "error";
|
||||
@@ -25,6 +26,8 @@ export type SetupErrorStage =
|
||||
|
||||
export interface SetupError {
|
||||
stage: SetupErrorStage;
|
||||
/** The backend's reason, coded or plain, when it sent one. */
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
// The backend reports real extraction percentages for most archive formats
|
||||
@@ -216,7 +219,10 @@ export function useBrowserSetup(browser: string, active: boolean) {
|
||||
doneRef.current = true;
|
||||
finishExtraction();
|
||||
setPhase("error");
|
||||
setError({ stage: toErrorStage(lastStageRef.current) });
|
||||
setError({
|
||||
stage: toErrorStage(lastStageRef.current),
|
||||
detail: p.error,
|
||||
});
|
||||
break;
|
||||
case "cancelled":
|
||||
// Treat a cancellation like an error so the dialog can offer retry.
|
||||
|
||||
Reference in new issue
Block a user