diff --git a/server/src/queries/asset.repository.sql b/server/src/queries/asset.repository.sql index 185afa562b..f7a4d1402d 100644 --- a/server/src/queries/asset.repository.sql +++ b/server/src/queries/asset.repository.sql @@ -170,27 +170,10 @@ where -- AssetRepository.getFileSamples select - "asset"."id", - "asset"."originalPath", - "asset"."sidecarPath", - "asset"."encodedVideoPath", - ( - select - coalesce(json_agg(agg), '[]') - from - ( - select - "path" - from - "asset_file" - where - "asset"."id" = "asset_file"."assetId" - ) as agg - ) as "files" + "assetId", + "path" from - "asset" -where - "asset"."libraryId" is null + "asset_file" limit 3 diff --git a/server/src/repositories/asset.repository.ts b/server/src/repositories/asset.repository.ts index 286a66e9af..8aa25c4a6a 100644 --- a/server/src/repositories/asset.repository.ts +++ b/server/src/repositories/asset.repository.ts @@ -1,6 +1,5 @@ import { Injectable } from '@nestjs/common'; import { Insertable, Kysely, NotNull, Selectable, UpdateResult, Updateable, sql } from 'kysely'; -import { jsonArrayFrom } from 'kysely/helpers/postgres'; import { isEmpty, isUndefined, omitBy } from 'lodash'; import { InjectKysely } from 'nestjs-kysely'; import { Stack } from 'src/database'; @@ -338,20 +337,7 @@ export class AssetRepository { @GenerateSql() getFileSamples() { - return this.db - .selectFrom('asset') - .select((eb) => [ - 'asset.id', - 'asset.originalPath', - 'asset.sidecarPath', - 'asset.encodedVideoPath', - jsonArrayFrom(eb.selectFrom('asset_file').select('path').whereRef('asset.id', '=', 'asset_file.assetId')).as( - 'files', - ), - ]) - .where('asset.libraryId', 'is', null) - .limit(sql.lit(3)) - .execute(); + return this.db.selectFrom('asset_file').select(['assetId', 'path']).limit(sql.lit(3)).execute(); } @GenerateSql({ params: [DummyValue.UUID] }) diff --git a/server/src/services/cli.service.ts b/server/src/services/cli.service.ts index 674b885dc4..38144e95b4 100644 --- a/server/src/services/cli.service.ts +++ b/server/src/services/cli.service.ts @@ -86,12 +86,7 @@ export class CliService extends BaseService { } for (const asset of assets) { - paths.push( - asset.originalPath, - asset.sidecarPath, - asset.encodedVideoPath, - ...asset.files.map((file) => file.path), - ); + paths.push(asset.path); } return paths.filter(Boolean) as string[]; diff --git a/server/src/services/storage.service.ts b/server/src/services/storage.service.ts index cd8910305a..bcfb34535c 100644 --- a/server/src/services/storage.service.ts +++ b/server/src/services/storage.service.ts @@ -97,18 +97,18 @@ export class StorageService extends BaseService { const current = StorageCore.getMediaLocation(); const samples = await this.assetRepository.getFileSamples(); if (samples.length > 0) { - const originalPath = samples[0].originalPath; + const path = samples[0].path; const savedValue = await this.systemMetadataRepository.get(SystemMetadataKey.MediaLocation); let previous = savedValue?.location || ''; if (!previous) { - previous = originalPath.startsWith('upload/') ? 'upload' : '/usr/src/app/upload'; + previous = path.startsWith('upload/') ? 'upload' : '/usr/src/app/upload'; } if (previous !== current) { this.logger.log(`Media location changed (from=${previous}, to=${current})`); - if (!originalPath.startsWith(previous)) { + if (!path.startsWith(previous)) { throw new Error( 'Detected an inconsistent media location. For more information, see https://immich.app/errors#inconsistent-media-location', );