From 7bb771a2032dc49c9031c95d1f2081d27e95dd0c Mon Sep 17 00:00:00 2001 From: Jamey Huffnagle Date: Thu, 12 Dec 2024 16:55:36 -0500 Subject: [PATCH] fix(app): fix manual file upload (#17098) The electron update made it no longer possible to access the file path from the renderer process, see #17010 for more details. That PR did not update one important case: uploading zip files. Currently, fun behavior happens when uploading a system zip, such as throwing an error or better yet, pushing an old, cache file instead of the expected system file. This commit fixes that. --- .../AdvancedTab/UpdateRobotSoftware.tsx | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/organisms/Desktop/Devices/RobotSettings/AdvancedTab/UpdateRobotSoftware.tsx b/app/src/organisms/Desktop/Devices/RobotSettings/AdvancedTab/UpdateRobotSoftware.tsx index a893c616508..55c64ee648a 100644 --- a/app/src/organisms/Desktop/Devices/RobotSettings/AdvancedTab/UpdateRobotSoftware.tsx +++ b/app/src/organisms/Desktop/Devices/RobotSettings/AdvancedTab/UpdateRobotSoftware.tsx @@ -23,6 +23,7 @@ import { ExternalLink } from '/app/atoms/Link/ExternalLink' import { TertiaryButton } from '/app/atoms/buttons' import { getRobotUpdateDisplayInfo } from '/app/redux/robot-update' import { useDispatchStartRobotUpdate } from '/app/redux/robot-update/hooks' +import { remote } from '/app/redux/shell/remote' import type { ChangeEventHandler, MouseEventHandler } from 'react' import type { State } from '/app/redux/types' @@ -55,14 +56,19 @@ export function UpdateRobotSoftware({ const handleChange: ChangeEventHandler = event => { const { files } = event.target - if (files?.length === 1 && !updateDisabled) { - dispatchStartRobotUpdate(robotName, files[0].path) - onUpdateStart() - } - // this is to reset the state of the file picker so users can reselect the same - // system image if the upload fails - if (inputRef.current?.value != null) { - inputRef.current.value = '' + + if (files != null) { + void remote.getFilePathFrom(files[0]).then(filePath => { + if (files.length === 1 && !updateDisabled) { + dispatchStartRobotUpdate(robotName, filePath) + onUpdateStart() + } + // this is to reset the state of the file picker so users can reselect the same + // system image if the upload fails + if (inputRef.current?.value != null) { + inputRef.current.value = '' + } + }) } }