mirror of
https://github.com/immich-app/immich.git
synced 2025-12-25 09:14:58 +03:00
fix(server): queueing for duplicate detection (#18380)
* fix queueing * update tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AssetFileType, AssetType, AssetVisibility, JobName, JobStatus } from 'src/enum';
|
||||
import { AssetType, AssetVisibility, JobName, JobStatus } from 'src/enum';
|
||||
import { DuplicateService } from 'src/services/duplicate.service';
|
||||
import { SearchService } from 'src/services/search.service';
|
||||
import { assetStub } from 'test/fixtures/asset.stub';
|
||||
@@ -11,17 +11,6 @@ vitest.useFakeTimers();
|
||||
const hasEmbedding = {
|
||||
id: 'asset-1',
|
||||
ownerId: 'user-id',
|
||||
files: [
|
||||
{
|
||||
assetId: 'asset-1',
|
||||
createdAt: new Date(),
|
||||
id: 'file-1',
|
||||
path: 'preview.jpg',
|
||||
type: AssetFileType.PREVIEW,
|
||||
updatedAt: new Date(),
|
||||
updateId: 'update-1',
|
||||
},
|
||||
],
|
||||
stackId: null,
|
||||
type: AssetType.IMAGE,
|
||||
duplicateId: null,
|
||||
@@ -218,15 +207,6 @@ describe(SearchService.name, () => {
|
||||
expect(mocks.logger.debug).toHaveBeenCalledWith(`Asset ${id} is not visible, skipping`);
|
||||
});
|
||||
|
||||
it('should fail if asset is missing preview image', async () => {
|
||||
mocks.assetJob.getForSearchDuplicatesJob.mockResolvedValue({ ...hasEmbedding, files: [] });
|
||||
|
||||
const result = await sut.handleSearchDuplicates({ id: assetStub.noResizePath.id });
|
||||
|
||||
expect(result).toBe(JobStatus.FAILED);
|
||||
expect(mocks.logger.warn).toHaveBeenCalledWith(`Asset ${assetStub.noResizePath.id} is missing preview image`);
|
||||
});
|
||||
|
||||
it('should fail if asset is missing embedding', async () => {
|
||||
mocks.assetJob.getForSearchDuplicatesJob.mockResolvedValue({ ...hasEmbedding, embedding: null });
|
||||
|
||||
|
||||
@@ -4,11 +4,10 @@ import { OnJob } from 'src/decorators';
|
||||
import { mapAsset } from 'src/dtos/asset-response.dto';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { DuplicateResponseDto } from 'src/dtos/duplicate.dto';
|
||||
import { AssetFileType, AssetVisibility, JobName, JobStatus, QueueName } from 'src/enum';
|
||||
import { AssetVisibility, JobName, JobStatus, QueueName } from 'src/enum';
|
||||
import { AssetDuplicateResult } from 'src/repositories/search.repository';
|
||||
import { BaseService } from 'src/services/base.service';
|
||||
import { JobItem, JobOf } from 'src/types';
|
||||
import { getAssetFile } from 'src/utils/asset.util';
|
||||
import { isDuplicateDetectionEnabled } from 'src/utils/misc';
|
||||
|
||||
@Injectable()
|
||||
@@ -65,17 +64,11 @@ export class DuplicateService extends BaseService {
|
||||
return JobStatus.SKIPPED;
|
||||
}
|
||||
|
||||
if (asset.visibility == AssetVisibility.HIDDEN) {
|
||||
if (asset.visibility === AssetVisibility.HIDDEN) {
|
||||
this.logger.debug(`Asset ${id} is not visible, skipping`);
|
||||
return JobStatus.SKIPPED;
|
||||
}
|
||||
|
||||
const previewFile = getAssetFile(asset.files || [], AssetFileType.PREVIEW);
|
||||
if (!previewFile) {
|
||||
this.logger.warn(`Asset ${id} is missing preview image`);
|
||||
return JobStatus.FAILED;
|
||||
}
|
||||
|
||||
if (!asset.embedding) {
|
||||
this.logger.debug(`Asset ${id} is missing embedding`);
|
||||
return JobStatus.FAILED;
|
||||
|
||||
Reference in New Issue
Block a user