mirror of
https://github.com/immich-app/immich.git
synced 2026-03-26 20:00:44 +03:00
fix(server): queue version check job when config changed (#27094)
Nothing happens when the version checks are enabled, which means the server may return very stale versions until the next job runs. Refs: #26935
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { SemVer } from 'semver';
|
import { SemVer } from 'semver';
|
||||||
|
import { defaults } from 'src/config';
|
||||||
import { serverVersion } from 'src/constants';
|
import { serverVersion } from 'src/constants';
|
||||||
import { ImmichEnvironment, JobName, JobStatus, SystemMetadataKey } from 'src/enum';
|
import { ImmichEnvironment, JobName, JobStatus, SystemMetadataKey } from 'src/enum';
|
||||||
import { VersionService } from 'src/services/version.service';
|
import { VersionService } from 'src/services/version.service';
|
||||||
@@ -130,6 +131,32 @@ describe(VersionService.name, () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('onConfigUpdate', () => {
|
||||||
|
it('should queue a version check job when newVersionCheck is enabled', async () => {
|
||||||
|
await sut.onConfigUpdate({
|
||||||
|
oldConfig: { ...defaults, newVersionCheck: { enabled: false } },
|
||||||
|
newConfig: { ...defaults, newVersionCheck: { enabled: true } },
|
||||||
|
});
|
||||||
|
expect(mocks.job.queue).toHaveBeenCalledWith({ name: JobName.VersionCheck, data: {} });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not queue a version check job when newVersionCheck is disabled', async () => {
|
||||||
|
await sut.onConfigUpdate({
|
||||||
|
oldConfig: { ...defaults, newVersionCheck: { enabled: true } },
|
||||||
|
newConfig: { ...defaults, newVersionCheck: { enabled: false } },
|
||||||
|
});
|
||||||
|
expect(mocks.job.queue).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not queue a version check job when newVersionCheck was already enabled', async () => {
|
||||||
|
await sut.onConfigUpdate({
|
||||||
|
oldConfig: { ...defaults, newVersionCheck: { enabled: true } },
|
||||||
|
newConfig: { ...defaults, newVersionCheck: { enabled: true } },
|
||||||
|
});
|
||||||
|
expect(mocks.job.queue).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('onWebsocketConnection', () => {
|
describe('onWebsocketConnection', () => {
|
||||||
it('should send on_server_version client event', async () => {
|
it('should send on_server_version client event', async () => {
|
||||||
await sut.onWebsocketConnection({ userId: '42' });
|
await sut.onWebsocketConnection({ userId: '42' });
|
||||||
|
|||||||
@@ -55,6 +55,13 @@ export class VersionService extends BaseService {
|
|||||||
return this.versionRepository.getAll();
|
return this.versionRepository.getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnEvent({ name: 'ConfigUpdate' })
|
||||||
|
async onConfigUpdate({ oldConfig, newConfig }: ArgOf<'ConfigUpdate'>) {
|
||||||
|
if (!oldConfig.newVersionCheck.enabled && newConfig.newVersionCheck.enabled) {
|
||||||
|
await this.handleQueueVersionCheck();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async handleQueueVersionCheck() {
|
async handleQueueVersionCheck() {
|
||||||
await this.jobRepository.queue({ name: JobName.VersionCheck, data: {} });
|
await this.jobRepository.queue({ name: JobName.VersionCheck, data: {} });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user