mirror of
https://github.com/immich-app/immich.git
synced 2025-04-21 07:26:25 +02:00
fix(server): backup version checks not handling database versions correctly (#14102)
This commit is contained in:
parent
2f9019c0e1
commit
e17bd8efc6
2 changed files with 8 additions and 8 deletions
server/src/services
|
@ -149,7 +149,6 @@ describe(BackupService.name, () => {
|
|||
storageMock.unlink.mockResolvedValue();
|
||||
systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);
|
||||
storageMock.createWriteStream.mockReturnValue(new PassThrough());
|
||||
databaseMock.getPostgresVersion.mockResolvedValue('14.3.2');
|
||||
});
|
||||
it('should run a database backup successfully', async () => {
|
||||
const result = await sut.handleBackupDatabase();
|
||||
|
@ -198,11 +197,13 @@ describe(BackupService.name, () => {
|
|||
expect(result).toBe(JobStatus.FAILED);
|
||||
});
|
||||
it.each`
|
||||
postgresVersion | expectedVersion
|
||||
${'14.6.4'} | ${14}
|
||||
${'15.3.3'} | ${15}
|
||||
${'16.4.2'} | ${16}
|
||||
${'17.15.1'} | ${17}
|
||||
postgresVersion | expectedVersion
|
||||
${'14.10'} | ${14}
|
||||
${'14.10.3'} | ${14}
|
||||
${'14.10 (Debian 14.10-1.pgdg120+1)'} | ${14}
|
||||
${'15.3.3'} | ${15}
|
||||
${'16.4.2'} | ${16}
|
||||
${'17.15.1'} | ${17}
|
||||
`(
|
||||
`should use pg_dumpall $expectedVersion with postgres version $postgresVersion`,
|
||||
async ({ postgresVersion, expectedVersion }) => {
|
||||
|
|
|
@ -105,9 +105,8 @@ export class BackupService extends BaseService {
|
|||
const databaseVersion = await this.databaseRepository.getPostgresVersion();
|
||||
const databaseSemver = semver.coerce(databaseVersion);
|
||||
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}`);
|
||||
return JobStatus.FAILED;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue