@samitouri / QOSami-HFS / commits / c62604a5

fix: (regression 0.57.21) admin: on Windows, in the file-picker dialog, "root" and "parent folder" didn't always work

Massimo Melina committed Nov 22, 2025 at 14:48 UTC c62604a562004fee22cc23301223713a29dfa188
1 file changed +13 -10
admin/src/FilePicker.ts
+13 -10
@@ -1,7 +1,7 @@
1 // This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
2
3 import { createElement as h, Fragment, useEffect, useMemo, useRef, useState } from 'react'
4 -import { apiCall, useApiList } from './api'
4 +import { apiCall, useApi, useApiList } from './api'
5 import _ from 'lodash'
6 import { Alert, Box, Checkbox, ListItemIcon, ListItemText, MenuItem, TextField, Typography } from '@mui/material'
7 import { enforceFinal, formatBytes, isWindowsDrive, err2msg, basename, formatPerc } from './misc'
@@ -21,20 +21,23 @@ interface FilePickerProps {
21 files?: boolean
22 fileMask?: string
23 }
24 -let lastPath = ''
24 +let lastPath = '.'
25 export default function FilePicker({ onSelect, multiple=true, files=true, folders=true, fileMask, from=lastPath }: FilePickerProps) {
26 const [cwd, setCwd] = useState(from)
27 lastPath = cwd
28 const [ready, setReady] = useState(false)
29 const isWindows = useRef(false)
30 - useEffect(() => {
31 - apiCall('resolve_path', { path: from, closestFolder: true }).then(res => {
32 - if (typeof res.path === 'string') {
33 - setCwd(res.path)
34 - isWindows.current = res.path[1] === ':' || res.path.startsWith('\\\\') // drive or unc
35 - }
36 - }).finally(() => setReady(true))
37 - }, [from])
30 + useApi(!ready && 'resolve_path', { path: from, closestFolder: true }, { onResponse: async (_res, body) => {
31 + try {
32 + const {path} = body
33 + if (typeof path !== 'string') return
34 + setCwd(path)
35 + isWindows.current = path[1] === ':' || path.startsWith('\\\\') // drive or unc
36 + }
37 + finally {
38 + setReady(true)
39 + }
40 + } })
41 const { list, props, error, connecting, reload } = useApiList<LsEntry>(ready && 'get_ls', { path: cwd, files, fileMask })
42 useEffect(() => {
43 setSel([])