Skip to content

Commit

Permalink
fix(app): fix manual file upload (#17098)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mjhuff authored Dec 12, 2024
1 parent f8cdc82 commit 7bb771a
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -55,14 +56,19 @@ export function UpdateRobotSoftware({

const handleChange: ChangeEventHandler<HTMLInputElement> = 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 = ''
}
})
}
}

Expand Down

0 comments on commit 7bb771a

Please sign in to comment.