Comment
This commit is contained in:
parent
10f2c3db6f
commit
9dd865ff6e
2 changed files with 17 additions and 5 deletions
|
@ -325,13 +325,26 @@ export default function Uploader({
|
|||
|
||||
// Trigger an upload when any of the dependencies change.
|
||||
useEffect(() => {
|
||||
// Re the paths:
|
||||
//
|
||||
// - These are not necessarily the full paths. In particular, when
|
||||
// running on the browser they'll be the relative paths (at best) or
|
||||
// just the file-name otherwise.
|
||||
//
|
||||
// - All the paths use POSIX separators. See inline comments.
|
||||
const allItemAndPaths = [
|
||||
// See: [Note: webkitRelativePath]. In particular, they use POSIX
|
||||
// separators.
|
||||
webFiles.map((f) => [f, f.webkitRelativePath ?? f.name]),
|
||||
// The paths we get from the desktop app all eventually come either
|
||||
// from electron.selectDirectory or electron.pathForFile, both of
|
||||
// which return POSIX paths.
|
||||
desktopFiles.map((fp) => [fp, fp.path]),
|
||||
desktopFilePaths.map((p) => [p, p]),
|
||||
// ze[1], the entry name, uses POSIX separators.
|
||||
// The first path, that of the zip file itself, is POSIX like the
|
||||
// other paths we get over the IPC boundary. And the second path,
|
||||
// ze[1], the entry name, uses POSIX separators because that is what
|
||||
// the ZIP format uses.
|
||||
desktopZipItems.map((ze) => [ze, ze[1]]),
|
||||
].flat() as [UploadItem, string][];
|
||||
|
||||
|
@ -794,10 +807,7 @@ async function waitAndRun(
|
|||
await task();
|
||||
}
|
||||
|
||||
const desktopFilesAndZipItems = async (
|
||||
electron: Electron,
|
||||
files: File[],
|
||||
): Promise<{ fileAndPaths: FileAndPath[]; zipItems: ZipItem[] }> => {
|
||||
const desktopFilesAndZipItems = async (electron: Electron, files: File[]) => {
|
||||
const fileAndPaths: FileAndPath[] = [];
|
||||
let zipItems: ZipItem[] = [];
|
||||
|
||||
|
|
|
@ -53,6 +53,8 @@ export interface Electron {
|
|||
* Ask the user to select a directory on their local file system, and return
|
||||
* it path.
|
||||
*
|
||||
* The returned path is guaranteed to use POSIX separators ('/').
|
||||
*
|
||||
* We don't strictly need IPC for this, we can use a hidden <input> element
|
||||
* and trigger its click for the same behaviour (as we do for the
|
||||
* `useFileInput` hook that we use for uploads). However, it's a bit
|
||||
|
|
Loading…
Add table
Reference in a new issue