Skip to content

Commit 2439aab

Browse files
committed
lil more
1 parent 3c1b326 commit 2439aab

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/app/Flash.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const errors = {
113113
},
114114
[ErrorCode.FLASH_SYSTEM_FAILED]: {
115115
status: 'Flash failed',
116-
description: 'AGNOS could not be flashed to your device. Try using a different cable, USB port, or computer. If ' +
116+
description: 'Try using a different cable, USB port, or computer. If ' +
117117
'the problem persists, join the #hw-three-3x channel on Discord for help.',
118118
icon: deviceExclamation,
119119
},
@@ -659,8 +659,8 @@ export default function Flash() {
659659
title = status
660660
}
661661

662-
// warn the user if they try to leave the page while flashing
663-
if (step >= StepCode.REPAIR_PARTITION_TABLES && step <= StepCode.FINALIZING) {
662+
// warn the user if they try to leave the page while flashing (but not if there's an error)
663+
if (step >= StepCode.REPAIR_PARTITION_TABLES && step <= StepCode.FINALIZING && error === ErrorCode.NONE) {
664664
window.addEventListener("beforeunload", beforeUnloadListener, { capture: true })
665665
} else {
666666
window.removeEventListener("beforeunload", beforeUnloadListener, { capture: true })
@@ -692,7 +692,7 @@ export default function Flash() {
692692
</div>
693693
<span className="text-3xl dark:text-white font-mono font-light">{title}</span>
694694
<span className="text-xl dark:text-white px-8 max-w-xl text-center">{description}</span>
695-
{error && (
695+
{error !== ErrorCode.NONE && (
696696
<button
697697
className="px-4 py-2 rounded-md bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 transition-colors"
698698
onClick={handleRetry}

src/utils/image.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ export class ImageManager {
2020
async init() {
2121
if (!this.root) {
2222
this.root = await navigator.storage.getDirectory()
23-
await this.root.remove({ recursive: true })
23+
// Clean up any leftover files from previous sessions
24+
try {
25+
await this.root.remove({ recursive: true })
26+
} catch (e) {
27+
// Ignore errors - directory might not exist or be empty
28+
console.debug('[ImageManager] Could not remove old directory:', e)
29+
}
30+
// Re-get the directory after removal
31+
this.root = await navigator.storage.getDirectory()
2432
console.info('[ImageManager] Initialized')
2533
}
2634

src/utils/manager.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,10 @@ export class FlashManager {
188188
} catch (err) {
189189
console.error('[Flash] Failed to initialize image worker')
190190
console.error(err)
191-
if (err instanceof String && err.startsWith('Not enough storage')) {
191+
const message = err?.message || String(err)
192+
if (message.startsWith('Not enough storage')) {
192193
this.#setError(ErrorCode.STORAGE_SPACE)
193-
this.#setMessage(err)
194+
this.#setMessage(message)
194195
} else {
195196
this.#setError(ErrorCode.UNKNOWN)
196197
}

0 commit comments

Comments
 (0)