mirror of
https://github.com/immich-app/immich.git
synced 2025-12-29 09:14:59 +03:00
Merge branch 'main' of https://github.com/immich-app/immich into feat/sidecar-asset-files
This commit is contained in:
@@ -75,14 +75,15 @@ select
|
||||
"asset_file"
|
||||
where
|
||||
"asset_file"."assetId" = "asset"."id"
|
||||
and "asset_file"."type" = $1
|
||||
) as agg
|
||||
) as "files"
|
||||
from
|
||||
"asset"
|
||||
where
|
||||
"asset"."id" = $1::uuid
|
||||
"asset"."id" = $2::uuid
|
||||
limit
|
||||
$2
|
||||
$3
|
||||
|
||||
-- AssetJobRepository.streamForThumbnailJob
|
||||
select
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function down(db: Kysely<any>): Promise<void> {
|
||||
UPDATE asset
|
||||
SET "sidecarPath" = asset_file.path
|
||||
FROM asset_file
|
||||
WHERE asset.id = asset_file."assetId";
|
||||
WHERE asset.id = asset_file."assetId" AND asset_file.type = 'sidecar';
|
||||
`.execute(db);
|
||||
|
||||
await sql`DELETE FROM asset_file WHERE type = 'sidecar';`.execute(db);
|
||||
|
||||
@@ -23,12 +23,12 @@ import { tagStub } from 'test/fixtures/tag.stub';
|
||||
import { factory } from 'test/small.factory';
|
||||
import { makeStream, newTestService, ServiceMocks } from 'test/utils';
|
||||
|
||||
function removeNonSidecarFiles(asset: any) {
|
||||
const removeNonSidecarFiles = (asset: any) => {
|
||||
return {
|
||||
...asset,
|
||||
files: asset.files.filter((file: any) => file.type === AssetFileType.Sidecar),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const forSidecarJob = (
|
||||
asset: {
|
||||
|
||||
@@ -361,7 +361,7 @@ export class MetadataService extends BaseService {
|
||||
break;
|
||||
}
|
||||
|
||||
const existingSidecar = asset.files ? asset.files.find((file) => file.type === AssetFileType.Sidecar) : null;
|
||||
const existingSidecar = asset.files?.find((file) => file.type === AssetFileType.Sidecar) ?? null;
|
||||
|
||||
const isChanged = sidecarPath !== existingSidecar?.path;
|
||||
|
||||
@@ -463,11 +463,7 @@ export class MetadataService extends BaseService {
|
||||
|
||||
private getExifTags(asset: { originalPath: string; files: AssetFile[]; type: AssetType }): Promise<ImmichTags> {
|
||||
if (asset.type === AssetType.Image) {
|
||||
let hasSidecar = false;
|
||||
|
||||
if (asset.files && asset.files.length > 0) {
|
||||
hasSidecar = asset.files.some((file) => file.type === AssetFileType.Sidecar);
|
||||
}
|
||||
const hasSidecar = asset.files?.some(({ type }) => type === AssetFileType.Sidecar);
|
||||
|
||||
if (!hasSidecar) {
|
||||
return this.metadataRepository.readTags(asset.originalPath);
|
||||
|
||||
@@ -450,7 +450,7 @@ export type StorageAsset = {
|
||||
fileCreatedAt: Date;
|
||||
originalPath: string;
|
||||
originalFileName: string;
|
||||
sidecarPath?: string | null;
|
||||
sidecarPath: string | null;
|
||||
fileSizeInByte: number | null;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user