refactor: event manager (#25481)

* refactor: event manager

* fix: broken downloadFile endpoint
This commit is contained in:
Jason Rasmussen
2026-01-23 18:02:23 -05:00
committed by GitHub
parent b52e8cd570
commit 4fedae4150
16 changed files with 45 additions and 116 deletions

View File

@@ -601,15 +601,15 @@ where
-- AssetRepository.getForThumbnail
select
"asset_file"."path",
"asset"."originalPath",
"asset"."originalFileName"
"asset"."originalFileName",
"asset_file"."path" as "path"
from
"asset_file"
right join "asset" on "asset"."id" = "asset_file"."assetId"
"asset"
left join "asset_file" on "asset"."id" = "asset_file"."assetId"
and "asset_file"."type" = $1
where
"asset_file"."assetId" = $1
and "asset_file"."type" = $2
"asset"."id" = $2
order by
"asset_file"."isEdited" desc

View File

@@ -1033,12 +1033,12 @@ export class AssetRepository {
@GenerateSql({ params: [DummyValue.UUID, AssetFileType.Preview] })
async getForThumbnail(id: string, type: AssetFileType) {
return this.db
.selectFrom('asset_file')
.select('asset_file.path')
.where('asset_file.assetId', '=', id)
.where('asset_file.type', '=', type)
.rightJoin('asset', (join) => join.onRef('asset.id', '=', 'asset_file.assetId'))
.select(['asset.originalPath', 'asset.originalFileName'])
.selectFrom('asset')
.where('asset.id', '=', id)
.leftJoin('asset_file', (join) =>
join.onRef('asset.id', '=', 'asset_file.assetId').on('asset_file.type', '=', type),
)
.select(['asset.originalPath', 'asset.originalFileName', 'asset_file.path as path'])
.orderBy('asset_file.isEdited', 'desc')
.executeTakeFirstOrThrow();
}

View File

@@ -597,15 +597,6 @@ describe(AssetMediaService.name, () => {
}),
);
});
it('should throw a not found when edits exist but no edited file available', async () => {
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1']));
mocks.asset.getForOriginal.mockResolvedValue({ ...assetStub.withCropEdit, editedPath: null });
await expect(sut.downloadOriginal(authStub.admin, 'asset-1', { edited: true })).rejects.toBeInstanceOf(
NotFoundException,
);
});
});
describe('viewThumbnail', () => {

View File

@@ -201,10 +201,6 @@ export class AssetMediaService extends BaseService {
dto.edited ?? false,
);
if (dto.edited && !editedPath) {
throw new NotFoundException('Edited asset media not found');
}
const path = editedPath ?? originalPath!;
return new ImmichFileResponse({
@@ -240,6 +236,10 @@ export class AssetMediaService extends BaseService {
return { targetSize: AssetMediaSize.PREVIEW };
}
if (!path) {
throw new NotFoundException('Asset media not found');
}
const fileName = `${getFileNameWithoutExtension(originalFileName)}_${size}${getFilenameExtension(path)}`;
return new ImmichFileResponse({