From 4063b4f597fcb54e09276ab654bfdce6d6bd789b Mon Sep 17 00:00:00 2001 From: Arsalan Sufi Date: Thu, 5 Oct 2023 22:47:46 -0400 Subject: [PATCH] Make sure saving backup on VxCentralScan doesn't crash app when no USB Also clear error message on subsequent backup attempts --- .../frontend/src/screens/admin_actions_screen.tsx | 1 + libs/backend/src/cast_vote_records/export.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/central-scan/frontend/src/screens/admin_actions_screen.tsx b/apps/central-scan/frontend/src/screens/admin_actions_screen.tsx index 9c2c19a694b..c8b35b3301e 100644 --- a/apps/central-scan/frontend/src/screens/admin_actions_screen.tsx +++ b/apps/central-scan/frontend/src/screens/admin_actions_screen.tsx @@ -96,6 +96,7 @@ export function AdminActionsScreen({ function saveBackup() { setIsBackingUp(true); + setBackupError(''); exportCastVoteRecordsToUsbDriveMutation.mutate( { isMinimalExport: false }, { diff --git a/libs/backend/src/cast_vote_records/export.ts b/libs/backend/src/cast_vote_records/export.ts index 08e3cece62d..96e5902d706 100644 --- a/libs/backend/src/cast_vote_records/export.ts +++ b/libs/backend/src/cast_vote_records/export.ts @@ -13,6 +13,7 @@ import { import { assert, assertDefined, + err, ok, Result, throwIllegalValue, @@ -673,7 +674,9 @@ export async function exportCastVoteRecordsToUsbDrive( ? usbDriveStatus.mountPoint : undefined; } - assert(usbMountPoint !== undefined); + if (usbMountPoint === undefined) { + return err({ type: 'missing-usb-drive' }); + } const exportContext: ExportContext = { exporter: new Exporter({ allowedExportPatterns: SCAN_ALLOWED_EXPORT_PATTERNS,