mirror of
https://github.com/immich-app/immich.git
synced 2025-12-29 01:11:52 +03:00
refactor: dedicated query for asset migration job (#17631)
This commit is contained in:
@@ -191,13 +191,14 @@ describe(MediaService.name, () => {
|
||||
|
||||
describe('handleAssetMigration', () => {
|
||||
it('should fail if asset does not exist', async () => {
|
||||
mocks.assetJob.getForMigrationJob.mockResolvedValue(void 0);
|
||||
await expect(sut.handleAssetMigration({ id: assetStub.image.id })).resolves.toBe(JobStatus.FAILED);
|
||||
|
||||
expect(mocks.move.getByEntity).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should move asset files', async () => {
|
||||
mocks.asset.getByIds.mockResolvedValue([assetStub.image]);
|
||||
mocks.assetJob.getForMigrationJob.mockResolvedValue(assetStub.image);
|
||||
mocks.move.create.mockResolvedValue({
|
||||
entityId: assetStub.image.id,
|
||||
id: 'move-id',
|
||||
|
||||
@@ -121,7 +121,7 @@ export class MediaService extends BaseService {
|
||||
@OnJob({ name: JobName.MIGRATE_ASSET, queue: QueueName.MIGRATION })
|
||||
async handleAssetMigration({ id }: JobOf<JobName.MIGRATE_ASSET>): Promise<JobStatus> {
|
||||
const { image } = await this.getConfig({ withCache: true });
|
||||
const [asset] = await this.assetRepository.getByIds([id], { files: true });
|
||||
const asset = await this.assetJobRepository.getForMigrationJob(id);
|
||||
if (!asset) {
|
||||
return JobStatus.FAILED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user