Skip to content

armgit / ente

Public Imported from GitHub
0

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

Index new

Manav Rathi00de818e6583
diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.ts
index e126e935cf..a5039ad432 100644
--- a/web/apps/photos/src/services/upload/uploadManager.ts
+++ b/web/apps/photos/src/services/upload/uploadManager.ts
@@ -1,7 +1,7 @@
import { FILE_TYPE } from "@/media/file-type";
import { potentialFileTypeFromExtension } from "@/media/live-photo";
import { getLocalFiles } from "@/new/photos/services/files";
-import { onUpload as onUploadML } from "@/new/photos/services/ml";
+import { indexNewlyUploadedFile } from "@/new/photos/services/ml";
import type { UploadItem } from "@/new/photos/services/upload/types";
import {
RANDOM_PERCENTAGE_PROGRESS_FOR_PUT,
@@ -635,7 +635,8 @@ class UploadManager {
enteFile: decryptedFile,
localFile: file,
});
- onUploadML(decryptedFile, file);
+ if (UPLOAD_RESULT.UPLOADED == uploadResult)
+ indexNewlyUploadedFile(decryptedFile, file);
} catch (e) {
log.warn("Ignoring error in fileUploaded handlers", e);
}
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts
index 97b6e09a72..e37ba6d8d7 100644
--- a/web/packages/new/photos/services/ml/index.ts
+++ b/web/packages/new/photos/services/ml/index.ts
@@ -161,14 +161,23 @@ export const triggerMLSync = () => {
};
/**
- * Called by the uploader when it uploads a new file from this client.
+ * Run indexing on a file which was uploaded from this client.
+ *
+ * This function is called by the uploader when it uploads a new file from this
+ * client, giving us the opportunity to index it live. This is only an
+ * optimization - if we don't index it now it'll anyways get indexed later as
+ * part of the batch jobs, but that might require downloading the file's
+ * contents again.
*
* @param enteFile The {@link EnteFile} that got uploaded.
*
* @param file When available, the web {@link File} object representing the
* contents of the file that got uploaded.
*/
-export const onUpload = (enteFile: EnteFile, file: File | undefined) => {
+export const indexNewlyUploadedFile = (
+ enteFile: EnteFile,
+ file: File | undefined,
+) => {
if (!_isMLEnabled) return;
if (enteFile.metadata.fileType !== FILE_TYPE.IMAGE) return;
log.debug(() => ({ t: "ml-liveq", enteFile, file }));