Skip to content

armgit / ente

Public Imported from GitHub
0

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

done

Manav Rathic76b2f07945e
diff --git a/web/apps/photos/src/utils/native-stream.ts b/web/apps/photos/src/utils/native-stream.ts
index 8a55fe33d1..e922c26219 100644
--- a/web/apps/photos/src/utils/native-stream.ts
+++ b/web/apps/photos/src/utils/native-stream.ts
@@ -166,3 +166,24 @@ export const readConvertToMP4Stream = async (
return res.blob();
};
+
+/**
+ * Sibling of {@link readConvertToMP4Stream} to let the native side know when we
+ * are done reading the response, and they can dispose any temporary resources
+ * it was using.
+ *
+ * @param token A token obtained from {@link writeConvertToMP4Stream}.
+ */
+export const readConvertToMP4Done = async (
+ _: Electron,
+ token: string,
+): Promise<void> => {
+ // The value for `done` is arbitrary, only its presence matters.
+ const params = new URLSearchParams({ token, done: "1" });
+ const url = new URL(`stream://convert-to-mp4?${params.toString()}`);
+
+ const req = new Request(url, { method: "GET" });
+ const res = await fetch(req);
+ if (!res.ok)
+ throw new Error(`Failed to close stream at ${url}: HTTP ${res.status}`);
+};