diff --git a/mobile/openapi/lib/model/job_command.dart b/mobile/openapi/lib/model/job_command.dart index 4ebdec26b4..6da91e2326 100644 --- a/mobile/openapi/lib/model/job_command.dart +++ b/mobile/openapi/lib/model/job_command.dart @@ -25,12 +25,14 @@ class JobCommand { static const start = JobCommand._(r'start'); static const pause = JobCommand._(r'pause'); + static const resume = JobCommand._(r'resume'); static const empty = JobCommand._(r'empty'); /// List of all possible values in this [enum][JobCommand]. static const values = [ start, pause, + resume, empty, ]; @@ -72,6 +74,7 @@ class JobCommandTypeTransformer { switch (data.toString()) { case r'start': return JobCommand.start; case r'pause': return JobCommand.pause; + case r'resume': return JobCommand.resume; case r'empty': return JobCommand.empty; default: if (!allowNull) { diff --git a/server/immich-openapi-specs.json b/server/immich-openapi-specs.json index fe357c2756..1e5f48f163 100644 --- a/server/immich-openapi-specs.json +++ b/server/immich-openapi-specs.json @@ -4141,6 +4141,7 @@ "enum": [ "start", "pause", + "resume", "empty" ] }, diff --git a/server/libs/domain/src/job/job.constants.ts b/server/libs/domain/src/job/job.constants.ts index 2a75cd3d3b..d9d9f99725 100644 --- a/server/libs/domain/src/job/job.constants.ts +++ b/server/libs/domain/src/job/job.constants.ts @@ -12,6 +12,7 @@ export enum QueueName { export enum JobCommand { START = 'start', PAUSE = 'pause', + RESUME = 'resume', EMPTY = 'empty', } diff --git a/server/libs/domain/src/job/job.repository.ts b/server/libs/domain/src/job/job.repository.ts index ea6d6309ea..1c5594ec83 100644 --- a/server/libs/domain/src/job/job.repository.ts +++ b/server/libs/domain/src/job/job.repository.ts @@ -69,6 +69,7 @@ export const IJobRepository = 'IJobRepository'; export interface IJobRepository { queue(item: JobItem): Promise; pause(name: QueueName): Promise; + resume(name: QueueName): Promise; empty(name: QueueName): Promise; isActive(name: QueueName): Promise; getJobCounts(name: QueueName): Promise; diff --git a/server/libs/domain/src/job/job.service.spec.ts b/server/libs/domain/src/job/job.service.spec.ts index 42ce5e5144..9129b0a183 100644 --- a/server/libs/domain/src/job/job.service.spec.ts +++ b/server/libs/domain/src/job/job.service.spec.ts @@ -93,6 +93,12 @@ describe(JobService.name, () => { expect(jobMock.pause).toHaveBeenCalledWith(QueueName.METADATA_EXTRACTION); }); + it('should handle a resume command', async () => { + await sut.handleCommand(QueueName.METADATA_EXTRACTION, { command: JobCommand.RESUME, force: false }); + + expect(jobMock.resume).toHaveBeenCalledWith(QueueName.METADATA_EXTRACTION); + }); + it('should handle an empty command', async () => { await sut.handleCommand(QueueName.METADATA_EXTRACTION, { command: JobCommand.EMPTY, force: false }); diff --git a/server/libs/domain/src/job/job.service.ts b/server/libs/domain/src/job/job.service.ts index 2ca036280a..ccb1709aae 100644 --- a/server/libs/domain/src/job/job.service.ts +++ b/server/libs/domain/src/job/job.service.ts @@ -21,6 +21,9 @@ export class JobService { case JobCommand.PAUSE: return this.jobRepository.pause(queueName); + case JobCommand.RESUME: + return this.jobRepository.resume(queueName); + case JobCommand.EMPTY: return this.jobRepository.empty(queueName); } diff --git a/server/libs/domain/test/job.repository.mock.ts b/server/libs/domain/test/job.repository.mock.ts index 5b2d9547b2..a6c8fff2a1 100644 --- a/server/libs/domain/test/job.repository.mock.ts +++ b/server/libs/domain/test/job.repository.mock.ts @@ -4,6 +4,7 @@ export const newJobRepositoryMock = (): jest.Mocked => { return { empty: jest.fn(), pause: jest.fn(), + resume: jest.fn(), queue: jest.fn().mockImplementation(() => Promise.resolve()), isActive: jest.fn(), getJobCounts: jest.fn(), diff --git a/server/libs/infra/src/job/job.repository.ts b/server/libs/infra/src/job/job.repository.ts index 1fbacd840a..0371ab50df 100644 --- a/server/libs/infra/src/job/job.repository.ts +++ b/server/libs/infra/src/job/job.repository.ts @@ -45,6 +45,10 @@ export class JobRepository implements IJobRepository { return this.queueMap[name].pause(); } + resume(name: QueueName) { + return this.queueMap[name].resume(); + } + empty(name: QueueName) { return this.queueMap[name].empty(); } diff --git a/web/src/api/open-api/api.ts b/web/src/api/open-api/api.ts index 19546ee548..c139fef28f 100644 --- a/web/src/api/open-api/api.ts +++ b/web/src/api/open-api/api.ts @@ -1222,6 +1222,7 @@ export interface GetAssetCountByTimeBucketDto { export const JobCommand = { Start: 'start', Pause: 'pause', + Resume: 'resume', Empty: 'empty' } as const;