Remove an error that is never thrown
This commit is contained in:
parent
80a6fe16e7
commit
196090152c
3 changed files with 11 additions and 28 deletions
|
@ -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",
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue