( format: LinuxPackageFormat, file: string, error: unknown )
| 427 | } |
| 428 | |
| 429 | function handleLinuxInstallFailure( |
| 430 | format: LinuxPackageFormat, |
| 431 | file: string, |
| 432 | error: unknown |
| 433 | ): void { |
| 434 | const code = (error as { code?: string | number }).code |
| 435 | const hint = manualInstallHint(format, file) |
| 436 | |
| 437 | // pkexec isn't installed (no graphical askpass available). |
| 438 | if (code === 'ENOENT') { |
| 439 | revealDownloadedPackage(file) |
| 440 | setUpdateState( |
| 441 | nextStateFromInfo( |
| 442 | 'error', |
| 443 | lastInfo, |
| 444 | `Couldn't install automatically: pkexec (graphical sudo) isn't available on this system. The update was downloaded to ${file} — install it manually with: ${hint}, then reopen ZenNotes.` |
| 445 | ) |
| 446 | ) |
| 447 | return |
| 448 | } |
| 449 | |
| 450 | // pkexec exits 126/127 when the auth dialog is dismissed or not authorized. |
| 451 | // Keep the update ready so the user can retry. |
| 452 | if (code === 126 || code === 127) { |
| 453 | setUpdateState( |
| 454 | nextStateFromInfo( |
| 455 | 'downloaded', |
| 456 | lastInfo, |
| 457 | 'Update install was canceled. Click “Install and Relaunch” to try again.' |
| 458 | ) |
| 459 | ) |
| 460 | return |
| 461 | } |
| 462 | |
| 463 | // dpkg/apt (or rpm/pacman) failed. |
| 464 | revealDownloadedPackage(file) |
| 465 | const detail = error instanceof Error ? error.message.trim() : String(error) |
| 466 | setUpdateState( |
| 467 | nextStateFromInfo( |
| 468 | 'error', |
| 469 | lastInfo, |
| 470 | `Update install failed: ${detail || 'unknown error'}. The package is at ${file} — you can install it manually with: ${hint}.` |
| 471 | ) |
| 472 | ) |
| 473 | } |
no test coverage detected