mirror of
https://github.com/immich-app/immich.git
synced 2026-02-14 04:47:57 +03:00
refactor: event manager (#25481)
* refactor: event manager * fix: broken downloadFile endpoint
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user