Skip to content

armgit / ente

Public Imported from GitHub
0

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

Detect ML search status

Manav Rathi02abe24213e7
diff --git a/web/apps/photos/src/utils/storage/mlIDbStorage.ts b/web/apps/photos/src/utils/storage/mlIDbStorage.ts
index 8be60afacf..eec86e3a29 100644
--- a/web/apps/photos/src/utils/storage/mlIDbStorage.ts
+++ b/web/apps/photos/src/utils/storage/mlIDbStorage.ts
@@ -83,6 +83,34 @@ class MLIDbStorage {
log.error("ML Indexed DB blocking");
},
async upgrade(db, oldVersion, newVersion, tx) {
+ let wasMLSearchEnabled = false;
+ try {
+ const s: unknown = await tx
+ .objectStore("configs")
+ .getKey(ML_SEARCH_CONFIG_NAME);
+ if (typeof s == "string") {
+ const json = JSON.parse(s);
+ if (
+ json &&
+ typeof json == "object" &&
+ "enabled" in json
+ ) {
+ const enabled = json.enabled;
+ if (typeof enabled == "boolean") {
+ wasMLSearchEnabled = enabled;
+ }
+ }
+ }
+ } catch (e) {
+ log.error(
+ "Ignoring error while trying to determine ML search status during migration",
+ e,
+ );
+ }
+ log.info(
+ `Old database had wasMLSearchEnabled = ${wasMLSearchEnabled}`,
+ );
+
if (oldVersion < 1) {
const filesStore = db.createObjectStore("files", {
keyPath: "fileId",