Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Comment

Manav Rathi9dd865ff6e69
diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsx
index e56d7583e0..53ad1fb32f 100644
--- a/web/apps/photos/src/components/Upload/Uploader.tsx
+++ b/web/apps/photos/src/components/Upload/Uploader.tsx
@@ -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[] = [];
diff --git a/web/packages/next/types/ipc.ts b/web/packages/next/types/ipc.ts
index c851062410..fb72bcf5ca 100644
--- a/web/packages/next/types/ipc.ts
+++ b/web/packages/next/types/ipc.ts
@@ -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