High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
chore(server): search filename using originalFileName (#7691)
Alex1eea547aa2b6
diff --git a/server/src/infra/entities/asset.entity.ts b/server/src/infra/entities/asset.entity.tsindex 7335c3ddf7..96438a07df 100644--- a/server/src/infra/entities/asset.entity.ts+++ b/server/src/infra/entities/asset.entity.ts@@ -35,7 +35,7 @@ export const ASSET_CHECKSUM_CONSTRAINT = 'UQ_assets_owner_library_checksum';@Index('IDX_day_of_month', { synchronize: false })@Index('IDX_month', { synchronize: false })@Index('IDX_originalPath_libraryId', ['originalPath', 'libraryId'])-@Index('idx_originalpath_trigram', { synchronize: false })+@Index('idx_originalFileName_trigram', { synchronize: false })// For all assets, each originalpath must be unique per user and libraryexport class AssetEntity {@PrimaryGeneratedColumn('uuid')diff --git a/server/src/infra/infra.utils.ts b/server/src/infra/infra.utils.tsindex 652bced6b6..636d78ab70 100644--- a/server/src/infra/infra.utils.ts+++ b/server/src/infra/infra.utils.ts@@ -159,12 +159,12 @@ export function searchAssetBuilder(builder.andWhere(`${builder.alias}.ownerId IN (:...userIds)`, { userIds: options.userIds });}- const path = _.pick(options, ['encodedVideoPath', 'originalFileName', 'resizePath', 'webpPath']);+ const path = _.pick(options, ['encodedVideoPath', 'originalPath', 'resizePath', 'webpPath']);builder.andWhere(_.omitBy(path, _.isUndefined));- if (options.originalPath) {- builder.andWhere(`f_unaccent(${builder.alias}.originalPath) ILIKE f_unaccent(:originalPath)`, {- originalPath: `%${options.originalPath}%`,+ if (options.originalFileName) {+ builder.andWhere(`f_unaccent(${builder.alias}.originalFileName) ILIKE f_unaccent(:originalFileName)`, {+ originalFileName: `%${options.originalFileName}%`,});}diff --git a/server/src/infra/migrations/1709608140355-AddAssetOriginalPathTrigramIndex.ts b/server/src/infra/migrations/1709608140355-AddAssetOriginalPathTrigramIndex.tsindex fdca15cbff..1d4f13410a 100644--- a/server/src/infra/migrations/1709608140355-AddAssetOriginalPathTrigramIndex.ts+++ b/server/src/infra/migrations/1709608140355-AddAssetOriginalPathTrigramIndex.ts@@ -3,12 +3,12 @@ import { MigrationInterface, QueryRunner } from 'typeorm';export class AddAssetOriginalPathTrigramIndex1709608140355 implements MigrationInterface {public async up(queryRunner: QueryRunner): Promise<void> {await queryRunner.query(`- CREATE INDEX idx_originalpath_trigram+ CREATE INDEX idx_originalFileName_trigramON assets- USING gin (f_unaccent("originalPath") gin_trgm_ops)`);+ USING gin (f_unaccent("originalFileName") gin_trgm_ops)`);}public async down(queryRunner: QueryRunner): Promise<void> {- await queryRunner.query(`DROP INDEX "idx_originalpath_trigram"`);+ await queryRunner.query(`DROP INDEX "idx_originalFileName_trigram"`);}}diff --git a/web/src/lib/components/shared-components/search-bar/search-filter-box.svelte b/web/src/lib/components/shared-components/search-bar/search-filter-box.svelteindex d81ed566ca..b921f2bfd7 100644--- a/web/src/lib/components/shared-components/search-bar/search-filter-box.svelte+++ b/web/src/lib/components/shared-components/search-bar/search-filter-box.svelte@@ -94,7 +94,7 @@let payload: SmartSearchDto | MetadataSearchDto = {query: filter.context || undefined,- originalPath: filter.filename,+ originalFileName: filter.filename,country: filter.location.country,state: filter.location.state,city: filter.location.city,diff --git a/web/src/routes/(user)/search/+page.svelte b/web/src/routes/(user)/search/+page.svelteindex 3b7d6b8e6e..c9893166f9 100644--- a/web/src/routes/(user)/search/+page.svelte+++ b/web/src/routes/(user)/search/+page.svelte@@ -173,7 +173,7 @@make: 'Camera brand',model: 'Camera model',personIds: 'People',- originalPath: 'File name',+ originalFileName: 'File name',};return keyMap[key] || key;}