mirror of
https://github.com/immich-app/immich.git
synced 2025-06-01 04:36:19 -04:00
remove nesting
This commit is contained in:
parent
1691706666
commit
c15507baad
@ -32,7 +32,10 @@ export async function getVectorExtension(runner: Kysely<DB> | QueryRunner): Prom
|
|||||||
}
|
}
|
||||||
|
|
||||||
cachedVectorExtension = new ConfigRepository().getEnv().database.vectorExtension;
|
cachedVectorExtension = new ConfigRepository().getEnv().database.vectorExtension;
|
||||||
if (!cachedVectorExtension) {
|
if (cachedVectorExtension) {
|
||||||
|
return cachedVectorExtension;
|
||||||
|
}
|
||||||
|
|
||||||
let availableExtensions: { name: VectorExtension }[];
|
let availableExtensions: { name: VectorExtension }[];
|
||||||
const query = `SELECT name FROM pg_available_extensions WHERE name IN (${VECTOR_EXTENSIONS.map((ext) => `'${ext}'`).join(', ')})`;
|
const query = `SELECT name FROM pg_available_extensions WHERE name IN (${VECTOR_EXTENSIONS.map((ext) => `'${ext}'`).join(', ')})`;
|
||||||
if (runner instanceof Kysely) {
|
if (runner instanceof Kysely) {
|
||||||
@ -43,7 +46,6 @@ export async function getVectorExtension(runner: Kysely<DB> | QueryRunner): Prom
|
|||||||
}
|
}
|
||||||
const extensionNames = new Set(availableExtensions.map((row) => row.name));
|
const extensionNames = new Set(availableExtensions.map((row) => row.name));
|
||||||
cachedVectorExtension = VECTOR_EXTENSIONS.find((ext) => extensionNames.has(ext));
|
cachedVectorExtension = VECTOR_EXTENSIONS.find((ext) => extensionNames.has(ext));
|
||||||
}
|
|
||||||
if (!cachedVectorExtension) {
|
if (!cachedVectorExtension) {
|
||||||
throw new Error(`No vector extension found. Available extensions: ${VECTOR_EXTENSIONS.join(', ')}`);
|
throw new Error(`No vector extension found. Available extensions: ${VECTOR_EXTENSIONS.join(', ')}`);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user