Prepare for test

This commit is contained in:
Manav Rathi 2024-03-25 15:34:04 +05:30
parent 892bf852a5
commit f8a36852a6
No known key found for this signature in database
8 changed files with 36 additions and 8 deletions

View file

@ -108,6 +108,8 @@ export const attachIPCHandlers = () => {
ipcMain.handle("getEncryptionKey", (_) => getEncryptionKey());
// - App update
ipcMain.on("update-and-restart", (_) => updateAndRestart());
ipcMain.on("skip-app-update", (_, version) => skipAppUpdate(version));
@ -116,6 +118,8 @@ export const attachIPCHandlers = () => {
muteUpdateNotification(version),
);
// - Conversion
ipcMain.handle("convertToJPEG", (_, fileData, filename) =>
convertToJPEG(fileData, filename),
);
@ -137,6 +141,8 @@ export const attachIPCHandlers = () => {
) => runFFmpegCmd(cmd, inputFile, outputFileName, dontTimeout),
);
// - ML
ipcMain.handle(
"computeImageEmbedding",
(_, model: Model, imageData: Uint8Array) =>
@ -147,6 +153,8 @@ export const attachIPCHandlers = () => {
computeTextEmbedding(model, text),
);
// - File selection
ipcMain.handle("selectDirectory", (_) => selectDirectory());
ipcMain.handle("showUploadFilesDialog", (_) => showUploadFilesDialog());
@ -155,8 +163,12 @@ export const attachIPCHandlers = () => {
ipcMain.handle("showUploadZipDialog", (_) => showUploadZipDialog());
// - FS
ipcMain.handle("fsExists", (_, path) => fsExists(path));
// - FS Legacy
ipcMain.handle("checkExistsAndCreateDir", (_, dirPath) =>
checkExistsAndCreateDir(dirPath),
);
@ -187,6 +199,8 @@ export const attachIPCHandlers = () => {
rename(oldPath, newPath),
);
// - Upload
ipcMain.handle("getPendingUploads", (_) => getPendingUploads());
ipcMain.handle(
@ -214,6 +228,8 @@ export const attachIPCHandlers = () => {
* actual handlers.
*/
export const attachFSWatchIPCHandlers = (watcher: FSWatcher) => {
// - Watch
ipcMain.handle(
"addWatchMapping",
(

View file

@ -27,10 +27,11 @@
*/
import { contextBridge, ipcRenderer } from "electron";
import { setupLogging } from "./main/log";
import type { ElectronFile } from "./types";
setupLogging();
// TODO (MR): Uncomment and FIXME once preload is getting loaded.
// import { setupLogging } from "./main/log";
// setupLogging();
// - General

View file

@ -1,8 +1,8 @@
import chokidar from "chokidar";
import { BrowserWindow } from "electron";
import * as path from "path";
import { getWatchMappings } from "../api/watch";
import { logError } from "../main/log";
import { getWatchMappings } from "../services/watch";
import { getElectronFile } from "./fs";
/**

View file

@ -5,6 +5,7 @@ import * as fs from "node:fs/promises";
import * as path from "node:path";
import util from "util";
import { CustomErrors } from "../constants/errors";
import { writeStream } from "../main/fs";
import { isDev } from "../main/general";
import { logErrorSentry } from "../main/log";
import { Model } from "../types";
@ -12,7 +13,6 @@ import Tokenizer from "../utils/clip-bpe-ts/mod";
import { getPlatform } from "../utils/common/platform";
import { generateTempFilePath } from "../utils/temp";
import { deleteTempFile } from "./ffmpeg";
import { writeStream } from "./fs";
const shellescape = require("any-shell-escape");
const execAsync = util.promisify(require("child_process").exec);
const jpeg = require("jpeg-js");

View file

@ -5,9 +5,9 @@ import * as fs from "node:fs/promises";
import path from "path";
import util from "util";
import { CustomErrors } from "../constants/errors";
import { writeStream } from "../main/fs";
import { isDev } from "../main/general";
import { logError, logErrorSentry } from "../main/log";
import { writeStream } from "../services/fs";
import { ElectronFile } from "../types";
import { isPlatform } from "../utils/common/platform";
import { generateTempFilePath } from "../utils/temp";

View file

@ -57,7 +57,10 @@ class ImportService {
filePaths.push((fileWithCollection.file as ElectronFile).path);
}
}
await ElectronAPIs.setToUploadFiles(PICKED_UPLOAD_TYPE.FILES, filePaths);
await ElectronAPIs.setToUploadFiles(
PICKED_UPLOAD_TYPE.FILES,
filePaths,
);
}
async cancelRemainingUploads() {

View file

@ -427,7 +427,7 @@ class UploadManager {
this.setFiles((files) => sortFiles([...files, decryptedFile]));
}
private updateElectronRemainingFiles(
private async updateElectronRemainingFiles(
fileWithCollection: FileWithCollection,
) {
if (isElectron()) {

View file

@ -16,6 +16,12 @@ export enum FILE_PATH_TYPE {
ZIPS = "zips",
}
export enum PICKED_UPLOAD_TYPE {
FILES = "files",
FOLDERS = "folders",
ZIPS = "zips",
}
/**
* Extra APIs provided by the Node.js layer when our code is running in Electron
*
@ -205,7 +211,9 @@ export interface ElectronAPIsType {
type: string;
}>;
setToUploadFiles: (
type: FILE_PATH_TYPE,
/** TODO(MR): This is the actual type */
// type: FILE_PATH_TYPE,
type: PICKED_UPLOAD_TYPE,
filePaths: string[],
) => Promise<void>;
getElectronFilesFromGoogleZip: (