Skip to content

armgit / ente

Public Imported from GitHub
0

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

For real

Manav Rathi4eb51061cb63
diff --git a/desktop/src/main/stream.ts b/desktop/src/main/stream.ts
index 06c6e5fe93..bae13aa121 100644
--- a/desktop/src/main/stream.ts
+++ b/desktop/src/main/stream.ts
@@ -37,25 +37,18 @@ export const registerStreamProtocol = () => {
protocol.handle("stream", async (request: Request) => {
const url = request.url;
// The request URL contains the command to run as the host, and the
- // pathname of the file as the path. An additional path can be specified
- // as the URL hash.
- //
- // For example,
- //
- // stream://write/path/to/file#/path/to/another/file
- // host[pathname----] [pathname-2---------]
- //
+ // pathname of the file(s) as the search params.
const { host, searchParams } = new URL(url);
- const path = ensure(searchParams.get("path"));
- const path2 = searchParams.get("path2") ?? undefined;
- log.debug(() => `[stream] ${host} ${path}${path2 ? "::" + path2 : ""}`);
switch (host) {
case "read":
- return handleRead(path);
+ return handleRead(ensure(searchParams.get("path")));
case "read-zip":
- return handleReadZip(path, ensure(path2));
+ return handleReadZip(
+ ensure(searchParams.get("zipPath")),
+ ensure(searchParams.get("entryName")),
+ );
case "write":
- return handleWrite(path, request);
+ return handleWrite(ensure(searchParams.get("path")), request);
default:
return new Response("", { status: 404 });
}
diff --git a/web/apps/photos/src/utils/native-stream.ts b/web/apps/photos/src/utils/native-stream.ts
index 73c3522ede..941c5a9888 100644
--- a/web/apps/photos/src/utils/native-stream.ts
+++ b/web/apps/photos/src/utils/native-stream.ts
@@ -43,7 +43,7 @@ export const readStream = async (
url = new URL(`stream://read?${params.toString()}`);
} else {
const [zipPath, entryName] = pathOrZipItem;
- const params = new URLSearchParams({ path: zipPath, path2: entryName });
+ const params = new URLSearchParams({ zipPath, entryName });
url = new URL(`stream://read-zip?${params.toString()}`);
}
@@ -90,6 +90,9 @@ export const writeStream = async (
path: string,
stream: ReadableStream,
) => {
+ const params = new URLSearchParams({ path });
+ const url = new URL(`stream://write?${params.toString()}`);
+
// TODO(MR): This doesn't currently work.
//
// Not sure what I'm doing wrong here; I've opened an issue upstream
@@ -120,7 +123,7 @@ export const writeStream = async (
});
*/
- const req = new Request(`stream://write${path}`, {
+ const req = new Request(url, {
method: "POST",
body: await new Response(stream).blob(),
});