mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 12:15:47 -04:00
fix(server): backup version checks not handling database versions correctly (#14102)
This commit is contained in:
parent
2f9019c0e1
commit
e17bd8efc6
@ -149,7 +149,6 @@ describe(BackupService.name, () => {
|
|||||||
storageMock.unlink.mockResolvedValue();
|
storageMock.unlink.mockResolvedValue();
|
||||||
systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
|
systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
|
||||||
storageMock.createWriteStream.mockReturnValue(new PassThrough());
|
storageMock.createWriteStream.mockReturnValue(new PassThrough());
|
||||||
databaseMock.getPostgresVersion.mockResolvedValue('14.3.2');
|
|
||||||
});
|
});
|
||||||
it('should run a database backup successfully', async () => {
|
it('should run a database backup successfully', async () => {
|
||||||
const result = await sut.handleBackupDatabase();
|
const result = await sut.handleBackupDatabase();
|
||||||
@ -198,11 +197,13 @@ describe(BackupService.name, () => {
|
|||||||
expect(result).toBe(JobStatus.FAILED);
|
expect(result).toBe(JobStatus.FAILED);
|
||||||
});
|
});
|
||||||
it.each`
|
it.each`
|
||||||
postgresVersion | expectedVersion
|
postgresVersion | expectedVersion
|
||||||
${'14.6.4'} | ${14}
|
${'14.10'} | ${14}
|
||||||
${'15.3.3'} | ${15}
|
${'14.10.3'} | ${14}
|
||||||
${'16.4.2'} | ${16}
|
${'14.10 (Debian 14.10-1.pgdg120+1)'} | ${14}
|
||||||
${'17.15.1'} | ${17}
|
${'15.3.3'} | ${15}
|
||||||
|
${'16.4.2'} | ${16}
|
||||||
|
${'17.15.1'} | ${17}
|
||||||
`(
|
`(
|
||||||
`should use pg_dumpall $expectedVersion with postgres version $postgresVersion`,
|
`should use pg_dumpall $expectedVersion with postgres version $postgresVersion`,
|
||||||
async ({ postgresVersion, expectedVersion }) => {
|
async ({ postgresVersion, expectedVersion }) => {
|
||||||
|
@ -105,9 +105,8 @@ export class BackupService extends BaseService {
|
|||||||
const databaseVersion = await this.databaseRepository.getPostgresVersion();
|
const databaseVersion = await this.databaseRepository.getPostgresVersion();
|
||||||
const databaseSemver = semver.coerce(databaseVersion);
|
const databaseSemver = semver.coerce(databaseVersion);
|
||||||
const databaseMajorVersion = databaseSemver?.major;
|
const databaseMajorVersion = databaseSemver?.major;
|
||||||
const databaseSupported = semver.satisfies(databaseVersion, '>=14.0.0 <18.0.0');
|
|
||||||
|
|
||||||
if (!databaseMajorVersion || !databaseSupported) {
|
if (!databaseMajorVersion || !databaseSemver || !semver.satisfies(databaseSemver, '>=14.0.0 <18.0.0')) {
|
||||||
this.logger.error(`Database Backup Failure: Unsupported PostgreSQL version: ${databaseVersion}`);
|
this.logger.error(`Database Backup Failure: Unsupported PostgreSQL version: ${databaseVersion}`);
|
||||||
return JobStatus.FAILED;
|
return JobStatus.FAILED;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user