Skip to content

armgit / ente

Public Imported from GitHub
0

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

node 1

Manav Rathi2be8db783cbe
diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.ts
index b74b19ec6c..3782033bb8 100644
--- a/desktop/src/main/ipc.ts
+++ b/desktop/src/main/ipc.ts
@@ -182,10 +182,10 @@ export const attachIPCHandlers = () => {
"generateImageThumbnail",
(
_,
- dataOrPathOrZipItem: Uint8Array | string | ZipItem,
+ pathOrZipItem: string | ZipItem,
maxDimension: number,
maxSize: number,
- ) => generateImageThumbnail(dataOrPathOrZipItem, maxDimension, maxSize),
+ ) => generateImageThumbnail(pathOrZipItem, maxDimension, maxSize),
);
ipcMain.handle(
@@ -193,9 +193,9 @@ export const attachIPCHandlers = () => {
(
_,
command: FFmpegCommand,
- dataOrPathOrZipItem: Uint8Array | string | ZipItem,
+ pathOrZipItem: string | ZipItem,
outputFileExtension: string,
- ) => ffmpegExec(command, dataOrPathOrZipItem, outputFileExtension),
+ ) => ffmpegExec(command, pathOrZipItem, outputFileExtension),
);
// - Upload
diff --git a/desktop/src/main/services/ffmpeg.ts b/desktop/src/main/services/ffmpeg.ts
index 1b0e623faa..69edefafe0 100644
--- a/desktop/src/main/services/ffmpeg.ts
+++ b/desktop/src/main/services/ffmpeg.ts
@@ -8,7 +8,7 @@ import fs from "node:fs/promises";
import type { FFmpegCommand, ZipItem } from "../../types/ipc";
import {
deleteTempFileIgnoringErrors,
- makeFileForDataOrStreamOrPathOrZipItem,
+ makeFileForStreamOrPathOrZipItem,
makeTempFilePath,
} from "../utils/temp";
import type { FFmpegUtilityProcess } from "./ffmpeg-worker";
@@ -29,7 +29,7 @@ export const ffmpegUtilityProcess = () =>
*/
export const ffmpegExec = async (
command: FFmpegCommand,
- dataOrPathOrZipItem: Uint8Array | string | ZipItem,
+ pathOrZipItem: string | ZipItem,
outputFileExtension: string,
): Promise<Uint8Array> => {
const worker = await ffmpegUtilityProcess();
@@ -38,7 +38,7 @@ export const ffmpegExec = async (
path: inputFilePath,
isFileTemporary: isInputFileTemporary,
writeToTemporaryFile: writeToTemporaryInputFile,
- } = await makeFileForDataOrStreamOrPathOrZipItem(dataOrPathOrZipItem);
+ } = await makeFileForStreamOrPathOrZipItem(pathOrZipItem);
const outputFilePath = await makeTempFilePath(outputFileExtension);
try {
diff --git a/desktop/src/main/services/image.ts b/desktop/src/main/services/image.ts
index 7daa101d2a..0ac99299eb 100644
--- a/desktop/src/main/services/image.ts
+++ b/desktop/src/main/services/image.ts
@@ -6,7 +6,7 @@ import { type ZipItem } from "../../types/ipc";
import { execAsync, isDev } from "../utils/electron";
import {
deleteTempFileIgnoringErrors,
- makeFileForDataOrStreamOrPathOrZipItem,
+ makeFileForStreamOrPathOrZipItem,
makeTempFilePath,
} from "../utils/temp";
@@ -61,7 +61,7 @@ const vipsPath = () =>
);
export const generateImageThumbnail = async (
- dataOrPathOrZipItem: Uint8Array | string | ZipItem,
+ pathOrZipItem: string | ZipItem,
maxDimension: number,
maxSize: number,
): Promise<Uint8Array> => {
@@ -69,7 +69,7 @@ export const generateImageThumbnail = async (
path: inputFilePath,
isFileTemporary: isInputFileTemporary,
writeToTemporaryFile: writeToTemporaryInputFile,
- } = await makeFileForDataOrStreamOrPathOrZipItem(dataOrPathOrZipItem);
+ } = await makeFileForStreamOrPathOrZipItem(pathOrZipItem);
const outputFilePath = await makeTempFilePath("jpeg");
diff --git a/desktop/src/main/stream.ts b/desktop/src/main/stream.ts
index 85d572870f..58767c5ae1 100644
--- a/desktop/src/main/stream.ts
+++ b/desktop/src/main/stream.ts
@@ -14,7 +14,7 @@ import { writeStream } from "./utils/stream";
import {
deleteTempFile,
deleteTempFileIgnoringErrors,
- makeFileForDataOrStreamOrPathOrZipItem,
+ makeFileForStreamOrPathOrZipItem,
makeTempFilePath,
} from "./utils/temp";
@@ -292,7 +292,7 @@ const handleGenerateHLSWrite = async (
const objectUploadURL = params.get("objectUploadURL");
if (!objectUploadURL) throw new Error("Missing objectUploadURL");
- let inputItem: Parameters<typeof makeFileForDataOrStreamOrPathOrZipItem>[0];
+ let inputItem: Parameters<typeof makeFileForStreamOrPathOrZipItem>[0];
const path = params.get("path");
if (path) {
inputItem = path;
@@ -314,7 +314,7 @@ const handleGenerateHLSWrite = async (
path: inputFilePath,
isFileTemporary: isInputFileTemporary,
writeToTemporaryFile: writeToTemporaryInputFile,
- } = await makeFileForDataOrStreamOrPathOrZipItem(inputItem);
+ } = await makeFileForStreamOrPathOrZipItem(inputItem);
const outputFilePathPrefix = await makeTempFilePath();
let result: FFmpegGenerateHLSPlaylistAndSegmentsResult | undefined;
diff --git a/desktop/src/main/utils/temp.ts b/desktop/src/main/utils/temp.ts
index 67fd9ae1b9..ad874dd216 100644
--- a/desktop/src/main/utils/temp.ts
+++ b/desktop/src/main/utils/temp.ts
@@ -80,8 +80,8 @@ export const deleteTempFileIgnoringErrors = async (tempFilePath: string) => {
}
};
-/** The result of {@link makeFileForDataOrStreamOrPathOrZipItem}. */
-interface FileForDataOrPathOrZipItem {
+/** The result of {@link makeFileForStreamOrPathOrZipItem}. */
+interface FileForStreamOrPathOrZipItem {
/**
* The path to the file (possibly temporary).
*/
@@ -107,13 +107,13 @@ interface FileForDataOrPathOrZipItem {
* that needs to be deleted after processing, and a function to write the given
* {@link item} into that temporary file if needed.
*
- * @param item The contents of the file (bytes), or a {@link ReadableStream}
- * with the contents of the file, or the path to an existing file, or a (path to
- * a zip file, name of an entry within that zip file) tuple.
+ * @param item A {@link ReadableStream} with the contents of the file, or the
+ * path to an existing file, or a (path to a zip file, name of an entry within
+ * that zip file) tuple.
*/
-export const makeFileForDataOrStreamOrPathOrZipItem = async (
- item: Uint8Array | ReadableStream | string | ZipItem,
-): Promise<FileForDataOrPathOrZipItem> => {
+export const makeFileForStreamOrPathOrZipItem = async (
+ item: ReadableStream | string | ZipItem,
+): Promise<FileForStreamOrPathOrZipItem> => {
let path: string;
let isFileTemporary: boolean;
let writeToTemporaryFile = async () => {
@@ -126,9 +126,7 @@ export const makeFileForDataOrStreamOrPathOrZipItem = async (
} else {
path = await makeTempFilePath();
isFileTemporary = true;
- if (item instanceof Uint8Array) {
- writeToTemporaryFile = () => fs.writeFile(path, item);
- } else if (item instanceof ReadableStream) {
+ if (item instanceof ReadableStream) {
writeToTemporaryFile = () => writeStream(path, item);
} else {
writeToTemporaryFile = async () => {
diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts
index 20ace5ab8c..d923a72613 100644
--- a/desktop/src/preload.ts
+++ b/desktop/src/preload.ts
@@ -193,26 +193,26 @@ const convertToJPEG = (imageData: Uint8Array) =>
ipcRenderer.invoke("convertToJPEG", imageData);
const generateImageThumbnail = (
- dataOrPathOrZipItem: Uint8Array | string | ZipItem,
+ pathOrZipItem: string | ZipItem,
maxDimension: number,
maxSize: number,
) =>
ipcRenderer.invoke(
"generateImageThumbnail",
- dataOrPathOrZipItem,
+ pathOrZipItem,
maxDimension,
maxSize,
);
const ffmpegExec = (
command: FFmpegCommand,
- dataOrPathOrZipItem: Uint8Array | string | ZipItem,
+ pathOrZipItem: string | ZipItem,
outputFileExtension: string,
) =>
ipcRenderer.invoke(
"ffmpegExec",
command,
- dataOrPathOrZipItem,
+ pathOrZipItem,
outputFileExtension,
);