Browse Source

Remove an error that is never thrown

Manav Rathi 1 year ago
parent
commit
196090152c

+ 0 - 2
desktop/src/types/ipc.ts

@@ -50,8 +50,6 @@ export interface PendingUploads {
 export const CustomErrors = {
     WINDOWS_NATIVE_IMAGE_PROCESSING_NOT_SUPPORTED:
         "Windows native image processing is not supported",
-    UNSUPPORTED_PLATFORM: (platform: string, arch: string) =>
-        `Unsupported platform - ${platform} ${arch}`,
     MODEL_DOWNLOAD_PENDING:
         "Model download pending, skipping clip search request",
 };

+ 3 - 26
web/apps/photos/src/services/clip-service.ts

@@ -75,7 +75,6 @@ class CLIPService {
     private onFileUploadedHandler:
         | ((arg: { enteFile: EnteFile; localFile: globalThis.File }) => void)
         | null = null;
-    private unsupportedPlatform = false;
 
     constructor() {
         this.liveEmbeddingExtractionQueue = new PQueue({
@@ -85,7 +84,7 @@ class CLIPService {
     }
 
     isPlatformSupported = () => {
-        return isElectron() && !this.unsupportedPlatform;
+        return isElectron();
     };
 
     private logoutHandler = async () => {
@@ -99,9 +98,6 @@ class CLIPService {
 
     setupOnFileUploadListener = async () => {
         try {
-            if (this.unsupportedPlatform) {
-                return;
-            }
             if (this.onFileUploadedHandler) {
                 log.info("file upload listener already setup");
                 return;
@@ -188,26 +184,12 @@ class CLIPService {
         }
     };
 
-    getTextEmbedding = async (text: string): Promise<Float32Array> => {
-        try {
-            return ensureElectron().clipTextEmbedding(text);
-        } catch (e) {
-            if (e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)) {
-                this.unsupportedPlatform = true;
-            }
-            log.error("Failed to compute CLIP text embedding", e);
-            throw e;
-        }
+    getTextEmbedding = async (text: string) => {
+        return ensureElectron().clipTextEmbedding(text);
     };
 
     private runClipEmbeddingExtraction = async (canceller: AbortController) => {
         try {
-            if (this.unsupportedPlatform) {
-                log.info(
-                    `skipping clip embedding extraction, platform unsupported`,
-                );
-                return;
-            }
             const user = getData(LS_KEYS.USER);
             if (!user) {
                 return;
@@ -254,11 +236,6 @@ class CLIPService {
                             e,
                         );
                     }
-                    if (
-                        e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)
-                    ) {
-                        this.unsupportedPlatform = true;
-                    }
                     if (
                         e?.message === CustomError.REQUEST_CANCELLED ||
                         e?.message?.includes(CustomError.UNSUPPORTED_PLATFORM)

+ 8 - 0
web/packages/next/types/ipc.ts

@@ -200,6 +200,14 @@ export interface Electron {
 
     // - Conversion
 
+    /**
+     * Try to convert an arbitrary image into JPEG.
+     *
+     * The behaviour is OS dependent.
+     * @param fileData
+     * @param filename
+     * @returns
+     */
     convertToJPEG: (
         fileData: Uint8Array,
         filename: string,